Java syntax introduction (1): Basic composition of Java language

xiaoxiao2021-03-06  17

The Java language is mainly composed of the following five elements: identifiers, keywords, text, operators, and separators. These five elements have different syntax meanings and composition rules, which cooperate with each other to complete the language of Java language. Below we will explain separately.

1. Identifier variables, classes, and methods require a certain name, we call this name as identifier. There is a certain limit on the identifier in Java. First of all: The first character of all identifiers must be letters (case), underscore _ or dollar ¥; secondary marker is a number (0-9), all from A - Z's uppercase letters, A - Z's lowercase letters and underscore _, US dollar ¥ and all ASCII codes before hexadecimal 0xc0; third note indicator cannot use the keyword to be kept using the system.

The above is the basic rule named by the identifier. The following is a negative comparison table, which has a better understanding of the naming rules of the identifier:

Legal identifier illegal identifier Trytry # (Note: You cannot use # as the marker) Group_77group (Note: You can not start with digital symbol) OpenDooropen-door (Note: You can not use - as a marker) Boolean_1boolean (Note: Boolean is keyword Do not use the keyword to make a marker)

2. The keyword keyword is the identifier used by the Java language itself, which has its specific syntax meaning. All Java keywords will not be used as identifiers, and Java's keywords are:

Abstract,

CONTINUE,

For,

NEW,

Switch,

Boolean,

DEFAULT,

Goto,

NULL,

Synchronized,

Break,

DO,

IF,

Package,

this,

Byte,

Double,

IMPLEMENTS,

Private,

Threadsafe,

ByValue,

Else,

Import,

protected,

Throw,

Case,

Extends,

Instanceof,

PUBLIC,

TRANSIENT,

Catch,

False,

Int retturn,

True,

CHAR,

Final,

Interface,

SHORT,

TRY,

Class,

Finally,

Long,

STATIC,

Void,

CONST,

Float,

Native,

SUPER,

While et al.

3. Data type Java has different data types, Java's data types are: integer, floating point, Boolean, characters, string type. Integer data is the most common data type, its performance is: decimal, hexadecimal and octal. The hexadecimal integer must be started with 0x. Each integer data occupies 32-bit storage space, namely four bytes. This means that the integer data is represented, between -2, 147, 483, 648, and 2, 147, 483, 648, if you must represent a larger number, 64-bit long integer should be sufficient for some reason. If you want to force an integer as a long (Long), you can add alphabets L after the digital. Floating point data is used to represent a decimal number of decimal numbers. For example, 1.35 or 23.6. It is a standard form of floating point numbers, and it is also possible to use a scientific count method. Here are some examples:

3.1415926 0.34 .86.01234 9.999E8

The standard floating point is called a single precision floating point number, and its storage space is 32 bits, that is, four bytes. There are also 64-bit double precision floating point. You can use a D suffix to determine if you want to use this double precision floating point. The Boolean type is the simplest type of data. Boolean data has only two states: true and false, usually in both keyword true and false. Character data is a single character in a pair of single quotes. It can be any of the characters in the character set, such as 'a', 'b'. String data type is a character sequence enclosed in a pair of double quotes. The string data is actually implemented by the String class (class concept we will explain in detail in subsequent chapters) instead of the character arrays used in the C language. . Each string data will generate a new instance of a String class. The reader does not have to feel worried about the character string with the concept of the class. Due to the characteristics of the class, you don't have to worry about how to implement them, they will take care of themselves. It should be noted that the string is only for security considerations in Java. The following is given examples of several strings: "How are your"

I am student

4. Operator Any language has its own operator, Java language is no exception, such as , -, *, /, etc., the operator's role is to form an expression with a certain arithmetic data to complete the corresponding Operation. Different data types have different operators. 5. Separator separator is used to make the compiler to confirm where the code is separated. '' '' ';' ':' Is a separator of the Java language.

转载请注明原文地址:https://www.9cbs.com/read-67827.html

New Post(0)