Last active
September 1, 2020 09:32
-
-
Save SiAust/91d8cafcb28f6c07c280d0d483ce1e7a to your computer and use it in GitHub Desktop.
Reverse list getter
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
| Scanner sc = new Scanner(System.in); | |
| List<Integer> numbers = Arrays.stream(sc.nextLine().split(" ")) | |
| .mapToInt(Integer::parseInt).boxed().collect(Collectors.toList()); | |
| int index = sc.nextInt(); | |
| if (index < 0) { | |
| System.out.println(numbers.get(numbers.size() + index)); | |
| } else { | |
| System.out.println(numbers.get(index)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment