Home  >  Article  >  Java  >  What does a java identifier contain?

What does a java identifier contain?

青灯夜游
青灯夜游Original
2019-04-26 14:33:1016238browse

In the Java language, identifiers can contain numbers "0-9", letters "A-Z, a-z" and underscores "_", dollar signs "$" or RMB signs "¥"; but the first letter cannot be Numbers, and keywords and reserved words cannot be used as identifiers. Identifiers are case-sensitive.

What does a java identifier contain?

Java is an object-oriented programming language that can write cross-platform application software; Java technology has excellent versatility, efficiency, and platform portability and security, widely used in personal PCs, data centers, game consoles, scientific supercomputers, mobile phones and the Internet, and has the world's largest professional community of developers. In the global industrial environment of cloud computing and mobile Internet, Java has significant advantages and broad prospects.

In the Java language, variables, constants, functions, and statement blocks all have names. We call them Java identifiers; simply put, identifiers are used to give classes , objects, methods, variables, interfaces and custom data types are named.

Naming rules for java identifiers

● Java identifiers are composed of numbers, letters and underscores (_), dollar signs ($) Or composed of RMB symbol (¥).

●The first letter cannot be a number.

●You cannot use keywords and reserved words as identifiers.

● Identifiers are case-sensitive

Java programming specifications:

1), class name and interface name: according to "Camel Size "Peak method", the first letter of each word is capitalized, and the remaining letters are lowercase, including upper and lower case. Such as MyClass

2), method name: the first letter is lowercase, the remaining letters are uppercase, uppercase and lowercase; use underscores as little as possible. Such as bothEyesOfDoll.

3), package name: all letters are lowercase. For example, com.abc.dollapp.

4), Constant name: The constant name of the basic data type uses all capital letters, and the words are separated by underscores "_". Object constants can be mixed. For example: SIZE_NAME.

5), variable name: can be written in mixed case, the first character is lowercase, and the first letter of the word is capitalized as the separator between words. Don’t use underscores and use dollar signs sparingly. When naming variables, try to make them as clear as possible.

Related video tutorial recommendations: "Java Tutorial"

The above is the detailed content of What does a java identifier contain?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn