|
home—info—labs—hws—exams
textbook—java.lang docs—java.util docs—archive
A way of keeping track of a whole bunch of Strings
java.util.LinkedList<String> names = new java.util.LinkedList<String>(); names.add(0,"fred") names.add(1,"jill") names.add(2,"amy") |
Name of the class is long and awkward: java.util.LinkedList<String> (or java.util.LinkedList<Double> or java.util.LinkedList<java.awt.Rectangle> or …) Sure, you can use “import” to get on a first name basis with LinkedList<String>, but you do need to include the “<String>”.
A method to add things (to the end) of a LinkedList<Type>:
void add(Type val) |
The complementary method, to retrieve things which were previously put into the list:
void get(int i) |
At Codepad, we'll declare and init a list of Double, ithen we'll add and retrieve several items.
home—info—labs—hws—exams
textbook—java.lang docs—java.util docs—archive
©2008, Ian Barland, Radford University Last modified 2008.Nov.10 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |