Generic

  Generic 1, the ArrayList Generics 
  Public class ArrayListGenericDemo public static void main (String [] args) ArrayList <String> data = new ArrayList <String> (); 
  Data.add ( "hello"); 
  Data.add ( "goodbye"); 
  / / Data.add (new Date ()); This won't compile! 
  Iterator <String> it data.iterator = (); 
  While (it.hasNext ()) String s = it.next (); 
  System.out.println (s); 
  ) 
  ) 
  ) 2, the HashMap Generics 
  Public class ArrayListGenericDemo public static void main (String [] args) ArrayList <String> data = new ArrayList <String> (); 
  Data.add ( "hello"); 
  Data.add ( "goodbye"); 
  / / Data.add (new Date ()); This won't compile! 
  Iterator <String> it data.iterator = (); 
  While (it.hasNext ()) String s = it.next (); 
  System.out.println (s); 
  ) 
  ) 
  ) Posted on 2007-07-16 11:07 Aaronbamoo Reading (13) Comments (0) edit collections cited 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply