I am trying to create a char array, but am getting an error everytime i run my code. This is my code:
public static int namevalue(String name){
char[] charval={'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char let;
int val=0;
int letter;
int total=0;
int character;
for (letter=0;letter<name.length();letter++){
let=name.charAt(letter);
if (charval[letter]==let){
total+=letter;
}
total+=val;
}
return total;
}
And this is the error I am getting (main.java:10 is the line with the char array):
main.java:10: error: empty character literal char[] charval={'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
There is an arrow pointing towards the "'S', " part of my code in the debugger, and I am unsure why. If I remove that part, making it "'R', 'T', " the same error shows but pointed at the "'T'". Can someone please help me and tell me why? As far as I can tell, it is the same format as the other letters, which do not have an issue.
Thanks a lot