Answer the question
In order to leave comments, you need to log in
What is he doing ":"?
Please explain or provide a link. What does ":" do in the last loop?
public class testMethods
{
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 5; i++)
{
list.add(0, Integer.parseInt(reader.readLine()));
}
for (int n : list){
System.out.println(n);
}
}
}
Answer the question
In order to leave comments, you need to log in
This is foreach as far as I understood
stackoverflow.com/questions/1818729/java-foreach-l...
This is a for-each loop . Designed to iterate over containers so you don't have to mess around with iterators.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question