this part of my code should do the following:
- Check if input is a int-type (try-catch)
- if input is a int, check if it is in between the list:
Code
try{
id=sclocal.nextInt();
}catch(InputMismatchException exception)
{
System.out.println("Invalid input!");
}
id=sclocal.nextInt();
if(listperformer.size() <= id || id < 0)
{
System.out.println("Invalid input! 294");
return;
}
else
{
idlist.add(listperformer.get(id));
}
doesn't work. Problem: 1.
- if i put in a wrong ID he asks me to put in another and after this throws an exception
- if i put in a string throws an "InputMismatchException"
Aucun commentaire:
Enregistrer un commentaire