java - Print out certain elements in a list -


i have list of strings (list collection) question how print out first string,

linkedlist<string> list = new linkedlist<string>();         list.add("octopus");         list.add("fish");         list.add("shark"); 

to print out first item in list do:

system.out.println(list.get(0)); 

the .get(0); gets string @ index 0. lists start @ 0, first value in list @ index 0.

java docs .get(index) linkedlist.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -