So the following:
char x = 88;
int number = 8 + 'E';
char x = 'a' + 8;
are legal Java operations right?
‘Cause my Java teacher’s saying that ONLY characters enclosed in single quotes are legal for char and I have a test tomorrow so I want to make sure that I’m right and that she doesn’t mark me wrong.
Also, I tried playing around with int and things like int x = 40 + 'a' and char x = 5 + 'd' and they all yield the predicted results (If I refer to the ASCII chart) without any sort of errors.
Yes, you could use/assign both an integer (ASCII) value or a character itself to a
charvariable. The same value gets assigned to the variable ultimately.But your teacher may just be trying to suggest you a best practice, wherein using the characters rather than ASCII values is much more readable.