I am getting an "Invalid Character" error message for these identifiers. I think it is because of the apostrophe. How can I get them to work?
Double Semester’s_End;
Double Stonebinder’s_Familiar;
Double Mavinda,_Students'_Advocate;
I am getting an "Invalid Character" error message for these identifiers. I think it is because of the apostrophe. How can I get them to work?
Double Semester’s_End;
Double Stonebinder’s_Familiar;
Double Mavinda,_Students'_Advocate;
Because of the syntax definitions of the language, the only way to use an apostrophe in a java identifier is like this:
SemestersApostrophs_End
EndOfSemester
Semester_s_End
or similar, you get the idea.
I.e. in short, you can't.
In short: You can't. Use underscores to separate words if you want.
Also, in Java we use camelCase, where the first letter is small and the first letter of the next word is capitalized (unless it's a class, for which we use Regular).
Example:
double semestersEnd;
double stonebinder_s_Familiar;
double mavinda_StudentsAdvocate;
Also, when initializing/declaring, it's double
, not Double
(so it's a lower case d). Use: What is the difference between "Double" and "double" in Java?
As @jarmod provided, use this link for more info: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html.