I have been watching some LinkedList videos to try and understand what it is. But I see a lot of people having code like
for(String x : model)
Can anyone help me understand what ":" does in this code besides attaching x to "model" or is that all it does?
It means the loop will iterate through each object of the list
String xdeclares a String namedxmodelis the list of String you want to iterate through:is the operator making the compiler doing this operation.You can read the
forlike this : For eachStringinmodel, use x as variable and do the following operations.you can then use
xto do the operations you want on each elements of the list