I am trying to make a method that will validate a type of ID called gNum.
The gNum must be made up of 9 characters (first character being "G" and the rest being digits)
private boolean validateGNum (String gNum) {
boolean valid = false;
if(gNum.length() == 9) {
/*this is where I have a problem.
Trying to see how I can check if the first character of the
string 'gNum' is "G"
*/
if(gNum.charAt(0).equalsIgnoreCase("g")) {
for (int i=1; i < 9; i++) {
if(Character.isDigit(gNum.charAt(i))) {
valid = true;
}
}
}
}
return valid;
}
This is what I have and I get 'char cannot get dereferenced' error.
How can I fix this issue and make this code work?
Thank you