samedi 17 mars 2018

How to check if place in array is empty - Java

I want to check if in test[1] is empty, I have this code:

Scanner in = new Scanner(System.in);

String[] test = new String[3];
test=in.nextLine().split(" ");
    if(test[0].equalsIgnoreCase("asd")&&test[1].equals("")){
        System.out.println("Enter");
    }

But it says that test[1] is out of range in this array.

Aucun commentaire:

Enregistrer un commentaire