Instead of using arrays, try using a LinkedList:
LinkedList<Integer> numbers1 = new LinkedList<Integer>();
LinkedList<Integer> numbers2 = new LinkedList<Integer>();
while(true){
System.out.println("Enter number");
int number = new Scanner(System.in).nextInt();
if(number == -1){
if(numbers1.size() > 0){
break;
}else{
System.out.println("Need atleast one element inside list");
}
}else{
if(numbers1.size() <= 100){
numbers1.add(number);
}else{
System.out.println("Can't have more then 100 elements, ending list");
break;
}
}
}
while(true){
System.out.println("Enter number");
int number = new Scanner(System.in).nextInt();
if(number == -1){
if(numbers2.size() > 0){
break;
}else{
System.out.println("Need atleast one element inside list");
}
}else{
if(numbers2.size() <= 100){
numbers2.add(number);
}else{
System.out.println("Can't have more then 100 elements, ending list");
break;
}
}
}
for(int i = 0; i < numbers2.size(); i++){
System.out.println(String.format("%d: %s", numbers2.get(i), numbers1.contains(numbers2.get(i)) ? "is in list" : "not in list"));
}
I might be a little off with the brackets because I wrote that inside here instead of Eclipse, but yeah, you get the point.