LinkedList (Generics)
28 June 2008Like Vectors and ArrayLists, LinkedList can also be made to deal with only one type of objects. Lets see how to do that.
LinkedList<String> ll = new LinkedList<String>(); ll.add("Str1"); ll.add("Str2"); ll.addFirst("Str3");
The LinkedList named ll can only store String objects. This is very useful and provides more control over collection. You are always sure that you will get objects of a specific type from the list.
Related Posts:
- Using LinkedList (Collection)
- LinkedList - insertion/deletion
- Java Generics with legacy code (I)
- Java Generics with legacy code (II)
- More on Collection FrameWork
- Removing elements from a List
- Method parameters bounded by a Class
- Using Reflection to run methods
- Avoid unnecessary method calls
- Ant - pattern matching
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: LinkedList (Generics)