Last active
September 23, 2016 11:07
-
-
Save vndmtrx/1a56782c8d8179ba9e1ef6a27071ac0a to your computer and use it in GitHub Desktop.
Classe genérica simples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClasseGenerica<T> { | |
T ob; | |
ClasseGenerica(T o) { | |
ob = o; | |
} | |
T getob() { | |
return ob; | |
} | |
void mostraTipo() { | |
System.out.println("O tipo de T é " + ob.getClass().getName()); | |
} | |
public static void main(String args[]){ | |
ClasseGenerica<String> cls1 = new ClasseGenerica<String>("Teste"); | |
cls1.mostraTipo(); | |
ClasseGenerica<Integer> cls2 = new ClasseGenerica<Integer>(10); | |
cls2.mostraTipo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment