Skip to content

Instantly share code, notes, and snippets.

@mudiadamz
Created May 3, 2020 09:48
Show Gist options
  • Save mudiadamz/34db761a848162bbd034ad02398e9fce to your computer and use it in GitHub Desktop.
Save mudiadamz/34db761a848162bbd034ad02398e9fce to your computer and use it in GitHub Desktop.
package visitorpatern;
public class VisitorForLoop {
public static void main(final String[] args) {
//print all children using for loop
VisitorForLoop.printAllChildren(StaticData.PERSON);
}
static void printAllChildren(Person person){
for (Person person1: person.getChildren()){
System.out.println(person1.getName());
printAllChildren(person1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment