jeudi 28 janvier 2016

Checking position in string for specific character

I want to check the 3rd position of a string and if it isn't a : then display a message and end the program with return; Here is what I have tried to do:

if(!timeinput.charAt(3 =':')){
    System.out.println("Put the colon in the right place!");
    return;
}

but it keeps giving an error over the 3 after charAt saying I need a variable to the left. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire