Java Identifiers Rules and Best Practices
Identifiers (标识符)
In Java, an identifier is a symbol used to name various elements such as class names, method names, and variable names. Below are the important rules that govern Java identifiers:
- An identifier is a sequence of characters consisting of letters, digits, underscores (_), and dollar signs ($).
- An identifier must start with a letter, an underscore (_), or a dollar sign ($). It cannot start with a digit.
- An identifier cannot be a reserved word (e.g.,
class
,public
). - Java identifiers are case-sensitive, so
Scanner
andscanner
are different. - There is no length restriction for an identifier.
By following these rules, you can ensure your identifiers are valid and adhere to Java's standards.
1.43MB
文件大小:
评论区