HELP!!! Problems with Array: matching, sorting, etc
So here's my dilemma. I am suppose to have 2 sets of arrays that the user inputs. The program will have to sort through the arrays and check for duplicate integers. For example, if an array has a set [2,3,4,4,5] , it is equivalent to [2,3,4,5]. THEN, it tries to match with the second set of integers and check whether they're the same [2,3,4] [4,3,2] (order does not matter) ; different [2,3,4] [5,6,7] . There's more combinations but I am trying to go at it one by one. If you guys help me out here I would gladly appreciate it!
Code:
import java.util.Scanner;
import java.util.Arrays;
public class MatchingIntegers {
public static void main(String[] args) {
final int NUMBERS_IN_SET = 10;
int[] numbers1 = new int[NUMBERS_IN_SET];
int[] numbers2 = new int[NUMBERS_IN_SET];
Scanner input = new Scanner(System.in);
System.out.println("Enter the first set of numbers individually (#1 - 10)\n");
// Prompt user to input the first set of numbers
for (int i = 0; i < numbers1.length; i++) {
System.out.print("Enter a number: ");
// Convert string into integer
numbers1[i] = input.nextInt();
}
System.out.println("Enter the second set of numbers individually (#1 - 10).\n");
// Prompt user to input the second set of numbers
for (int i = 0; i < numbers2.length; i++) {
System.out.print("Enter a number: ");
// Convert string into integer
numbers2[i] = input.nextInt();
}
// Sort the whole arrays for both sets
java.util.Arrays.sort(numbers1);
java.util.Arrays.sort(numbers2);
// perform a linear search on the data
// Prepare the result
String output = " The first array is : ";
for (int i = 0; i < numbers1.length ; i++) {
output += numbers1[i] + " ";
}
// Display the result
System.out.println(output);
output = "The second array is : ";
for (int i = 0; i < numbers2.length ; i++) {
output += numbers2[i] + " ";
}
// Display the result
System.out.println(output);
}
}