I dont understand this for loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I dont understand this for loop

LinkedList<String> c = new LinkedList<String>(); c.add("Red"); c.add("Blue"); c.add("Green"); c.add("Orange"); c.remove("Green"); for(String s: c) { System.out.println(s); } /* Output: Red Blue Orange */ How does it know to check each string and how does it know to start and stop?

7th Oct 2016, 3:37 PM
Jesse Guerrero
Jesse Guerrero - avatar
1 Answer
0
loop foreach, read only forward the items
8th Oct 2016, 10:21 PM
Wanderlei Borges
Wanderlei Borges - avatar