-2

I have been looking at a friends java code and this came up. But im not sure what it is. Can anyone help quickly. The code is like this:

for(Customers cust: customerArrayList) {
//  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- fragment which I don't understand
Pshemo
  • 122,468
  • 25
  • 185
  • 269
Talha
  • 11
  • 4
  • I down voted because [Unclear what you're asking](http://idownvotedbecau.se/unclearquestion) – Timothy Truckle Jun 21 '21 at 17:48
  • Does it look something like `for (SomeElement oneElement : manyElements){..}`? If yes research "enhanced for loop". If no use [edit] option and provide more context (like fragment of code which contains what you are asking about). – Pshemo Jun 21 '21 at 17:51
  • Possibly related: [How does the Java 'for each' loop work?](https://stackoverflow.com/q/85190) – Pshemo Jun 21 '21 at 17:54
  • @Pshemo thanks a lot. i guess i got idea of it. Your comment helped – Talha Jun 21 '21 at 17:55
  • Why don't you just ask your friend. – DevilsHnd - 退職した Jun 21 '21 at 17:55
  • Related: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html (relevant fragment starts with "The for statement also has another form ...") – Pshemo Jun 21 '21 at 17:57
  • Also very nice resource: https://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html – Pshemo Jun 21 '21 at 18:07

1 Answers1

0

This is similar to following code :-

for(int i =0;i< customerArrayList.size();i++){
System.out.print(customerArrayList.get(i));
}
Ankur Saxena
  • 177
  • 1
  • 11