How to compare char
I'm trying to read a single character input and then decide what character it actually is. I can only figure out how to read a string input but not just a character input. Also, once I have that character I don't know the syntax to decide if that character is an A or B or whatever.
You can always get a char out of a String by String's charAt(...) method. If the String has length of 1, then charAt(0) will get that single character of the String and make it a char:
char c = "h".charAt(0);
Now I need to compare to see if the character is an A or B or...
This is my code:
String name = input.nextLine();
// do this if parcel is an envelope
if ( name == A ) // if result 1,
This give me an error saying 'name' cannot be resolved. I used the String method above to read the input because my teach suggested so. Can't get this to work now.