Skip to content

Instantly share code, notes, and snippets.

@SiAust
Last active June 8, 2020 09:02
Show Gist options
  • Save SiAust/8bbebf3f3e9d5e8a8c15b898aa58fa62 to your computer and use it in GitHub Desktop.
Save SiAust/8bbebf3f3e9d5e8a8c15b898aa58fa62 to your computer and use it in GitHub Desktop.
while loop and streams
// To get a int[] from a single space separated string
int[] range = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
// Nice way to do a simple loop
while (n-- > 0) { // nice way to do a loop, postfix decrement
// do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment