Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] arrOne = Arrays
- .stream(scanner.nextLine().split(" "))
- .mapToInt(Integer::parseInt)
- .toArray();
- int[] arrTwo = Arrays
- .stream(scanner.nextLine().split(" "))
- .mapToInt(Integer::parseInt)
- .toArray();
- if (Arrays.equals(arrOne, arrTwo)) {
- System.out.printf("Arrays are identical. Sum: %d\n", Arrays.stream(arrOne).sum());
- } else {
- for (int i = 0; i < arrOne.length; i++) {
- if (arrOne[i] != arrTwo[i]) {
- System.out.printf("Arrays are not identical. Found difference at %d index.\n", i);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement