Guest User

Untitled

a guest
Dec 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exercise_27 {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner input = new Scanner(System.in);
  8. System.out.print("Enter list1: ");
  9. int size = input.nextInt();
  10.  
  11. int[] list1 = new int[size];
  12. for (int i = 0; i < size; i++) list1[i] = input.nextInt();
  13.  
  14. System.out.print("Enter list2: ");
  15. size = input.nextInt();
  16.  
  17. int[] list2 = new int[size];
  18. for (int i = 0; i < size; i++) list2[i] = input.nextInt();
  19.  
  20. if (equals(list1, list2)) {
  21. System.out.println("Two lists are strictly identical");
  22. } else {
  23. System.out.println("Two lists are not strictly identical");
  24. }
  25.  
  26. }
  27.  
  28. public static boolean equals(int[] list1, int[] list2) {
  29.  
  30. if (list1.length != list2.length) return false;
  31.  
  32. for (int i = 0; i < list1.length; i++) {
  33. if (list1[i] != list2[i]) return false;
  34. }
  35.  
  36. return true;
  37. }
  38. }
Add Comment
Please, Sign In to add comment