Created
May 3, 2020 09:48
-
-
Save mudiadamz/34db761a848162bbd034ad02398e9fce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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