View RSS Feed

My Java Tips

LinkedList (Generics)

Rating: 1 votes, 1.00 average.
by , 11-03-2011 at 01:07 PM (1141 Views)
Like Vectors and ArrayLists, LinkedList can also be made to deal with only one type of objects. Lets see how to do that.



Java Code:
LinkedList ll = new LinkedList();
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.

Submit "LinkedList (Generics)" to Facebook Submit "LinkedList (Generics)" to Digg Submit "LinkedList (Generics)" to del.icio.us Submit "LinkedList (Generics)" to StumbleUpon Submit "LinkedList (Generics)" to Google

Tags: None Add / Edit Tags
Categories
Java SE

Comments