This is the first time that I’ve seen this kind of syntax :
// class Node
public class Node {
...
...
}
public class Otherclass { ... }
Otherclass graph = new Otherclass();
// getSuccessors is a method of Otherclass class
Node currentNode ;
List<Node> successors = graph.getSuccessors(currentNode);
// weird for loop
for (Node son : successors) {
// do something
}
What is that for loop ? some kind of a Matlab syntax ?
Is there any other way to write that for loop ?
Regards
It’s a for each loop. You could also write it like this:
Though the only time I’d personally do that is when the index is needed for doing something other than accessing the element.