How should identifiers and keywords be understood?

Thinking: Why are keywords and indicators needed in the language?

Programs come from life. Think about the language use of humans in the process of production and life has specific meanings. And each thing or some of the properties and functions of things also need to be given specific language symbols to express. Therefore, the inventors of the java language created a language worth learning in a human way.

Keywords and matters needing attention

Words that change color in the advanced development environment are keywords. Note that keywords cannot be used when naming class names, variable names, and method names.

Precautions:

Don’t memorize keywords in the learning process. It will continue to appear in the process of programming learning, and you will naturally remember when you knock it a few times.

Keyword
abstract assert boolean break

byte

case catch char class const
continue default do double

else

enum extends final finally float
for goto if implements import
instanceof int interface long native
new package private protected public
return strictfp short static super
switch synchronized this throw throws
transient try void volatile while

 

Identifier

The component classes of java contain attributes and functions, namely variables and methods. Class names, variable names, and method names need to have names, and the names must be standardized

  • All identifiers should start with a letter (AZ or az), dollar sign ($) or underscore (_)
  • The first letter can be (AZ or az), dollar sign ($) or underscore (_) or numbers
  • Keyword cannot be used as variable name or method name, otherwise it will be highlighted
  • The name of the identifier has different meanings
  • Chinese names can be used, but such use is not recommended, and it is best not to use pinyin.

Homework thinking:

Please find out which identifiers are conforming to the specification and which are not conforming to the specification in the following question

age、12sex、$salary、_value、_1_name、-phoneNumber、#abc

 

 

Guess you like

Origin blog.csdn.net/sinat_40775402/article/details/113099736