Вы присваиваете int массиву int.Вот почему у вас есть ошибка.Я не понимаю, почему вы используете массив.Используйте цикл, пользователю будет предложено ввести идентификатор, пока он не будет правильным.
public class Test
{
public static void main(String[] args)
{
int currentId;
while (true)
{
//asking user to enter a number
Scanner kb = new Scanner(System.in);
System.out.println("Enter and id number : ");
currentId = kb.nextInt();
//calling method
if (GetValidInteger(currentId))
{
//If the id is valid, you re out from the loop, if not retry
break;
}
}
}
//method
static boolean GetValidInteger(int currentId)
{
boolean isValidId = false;
boolean doesIdStartWith1 = String.valueOf(currentId).startsWith("1");
//if num at index 0 is 1 print out invalid
if (doesIdStartWith1)
{
System.out.println("The number you have entered :" + currentId + " starts with 1 and is invalid");
}
else
{
//else print out valid
System.out.println("The number you have entered :" + currentId + " is valid");
isValidId = true;
}
return isValidId;
}
}