public static boolean correctchar(char a) {
if (Character.toString(a).matches("^[a-z]") ) {
return true;
} else {
return false;
}
}
So for this code I need to make sure that the user can only enter one char, it works and returns true if the user enters one char but they can also enter other chars, for example "abcdefg" would be true because a matches a-z, however i need to make it so that the user can only enter one char. I'm also not sure how to make sure that the user does leave it null.
Aucun commentaire:
Enregistrer un commentaire