Home  >  Article  >  Java  >  what is java identifier

what is java identifier

(*-*)浩
(*-*)浩Original
2019-11-09 13:15:007762browse

In the Java language, an identifier is a string starting with a letter, underscore (_) or dollar sign ($) and consisting of letters, numbers, underscore (_) or dollar sign ($). Identifiers are case-sensitive and have no limit on length.

what is java identifier

In Java, we need to identify many elements of the code, including class names, methods , fields, variables, package names, etc. The name we choose is called an identifier and follows the following rules: (Recommended learning: java course )

(1) The identifier cannot be a keyword or true, false, null.

(2) Identifiers can contain letters, numbers 0-9, underscores (_), or dollar signs ($).

(3) The first character of the identifier must be a letter, underscore (_) or dollar sign ($).

(4) Identifiers are case-sensitive and have no maximum length specified.

Examples of legal identifiers: age, $salary, _value, __1_value Examples of illegal identifiers: 123abc, -salary

It is best to name the identifier to reflect its function and be visible. Know it

For example: The following identifier is legal:

myName,My_name,Points,$points,_sys_ta,OK,_23b,_3_,Myvoid

The following identifier is illegal:

#name,25name,class,&time,if

The above is the detailed content of what is java identifier. 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
Previous article:what is java methodNext article:what is java method