Guest User

Untitled

a guest
Jan 7th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public class Genericstring<T> {
  2.  
  3. String name;
  4.  
  5. public void set(String name){
  6.  
  7. this.name = name;
  8.  
  9. }
  10.  
  11. public static void main(String[] args){
  12.  
  13.  
  14. Genericstring<String> o = new Genericstring<String>();
  15. o.set("Generic");
  16.  
  17. System.out.println(o.name);
  18.  
  19. }
  20.  
  21.  
  22.  
  23. }
  24.  
  25. public class Genericstring<String> {
  26.  
  27. String name;
  28.  
  29. public static void main(String[] args){
  30.  
  31. Here creating object always having string type attributes. No need to specify like did in above example.
  32.  
  33.  
  34. }
Add Comment
Please, Sign In to add comment