Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@128keaton
Last active November 15, 2019 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 128keaton/e14dcdd0d9bd6ded8d365ed3ffa20caf to your computer and use it in GitHub Desktop.
Save 128keaton/e14dcdd0d9bd6ded8d365ed3ffa20caf to your computer and use it in GitHub Desktop.
public static void iterateListData(ListNode listNode) {
ListNode currentList = listNode;
int nestLevel = 0;
while (currentList != null ){
StringBuilder nestIndicator = new StringBuilder("→");
for (int i = 0; i < nestLevel; i++) {
nestIndicator.append("→");
}
System.out.println(nestIndicator + " data = " + currentList.data);
currentList = currentList.next;
nestLevel++;
}
System.out.println("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment