Can I name my java source code file with a number? -
this question has answer here:
- valid characters in java class name 8 answers
i'm saving source code java textbook exercises , realise have compilation error whenever save file using names " 2-15.java" along "public class 2-15" in source code
is there way can name starting number or profited in java?
from the language spec:
an identifier unlimited-length sequence of java letters , java digits, first of must java letter.
"letters":
"java letters" include uppercase , lowercase ascii latin letters a-z, , a-z, and, historical reasons, ascii underscore (_) , dollar sign ($).
"digits":
the "java digits" include ascii digits 0-9
your example fails because first character not "java letter" , dash not "java letter".
further, convention class names use uppercamelcase (also called 'pascalcase'), though not strictly required language.
some people argue shouldn't use digits @ in class names disagree this. can result in more readable names otherwise possible. example: aspectratio16x9
vs aspectratiosixteenbynine
Comments
Post a Comment