I really have no idea about this problem...
The block catches an exception if the number is not correct, when I put -1 or 0 it catches the Exception and asks me to input the number again... but if I type something like asdasd it will run an infinite loop.
while (true){
try{
System.out.println("-Size of the array: ");
size = read.nextInt();
if(size<=0){
throw new Exception();
}else{
break;
}
}
catch(Exception e){
System.out.println("\n-Wrong input. Try again.\n");
}
}