Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to distinguish constants from variables in Java programming?
How to distinguish constants from variables in Java programming?
Variable:

For example:

A, a 1, name and so on are all legal variables.

Description:

1)Java requires that the type of a variable be declared before using it.

2) The declaration of variables in Java is a complete Java statement, so a semicolon should be used at the end.

3) Naming rules for variables:

Variables must start with a letter.

A variable name is any combination of a series of letters or numbers.

In Java, a letter represents any character equivalent to a letter in Unicode.

In addition to 0-9, a number contains any Unicode character whose status is equivalent to a number.

+,copyright information symbol circle c and spaces cannot be used in variable names.

Variable names are case-sensitive.

There is basically no limit to the length of variable names.

If you want to know which Unicode Characters Java thinks are letters so far, you can use the isJavaIdentifierStart and isJavaIdentifierPart methods in the character class to check.

Java reserved words cannot be used in variable names.

4) Multiple variables can be declared in a statement, and different variables are separated by commas.

3. Constant:

Definition: A quantity whose value is constant is called a constant.

For example:

1, "Hello"

Description:

1) Use the final keyword to define a constant in Java.

int final a = 10; //Declare an integer constant a whose value is 10.

2) It is customary to capitalize the names of all constants.