Basic Components of Java

Source: Internet
Author: User
Tags comparison table java keywords

The Java language consists of the following five elements: identifier, keyword, text, operator, and separator. These five elements have different syntax meanings and composition rules. They work together to complete the semantic expression of the Java language. Next we will explain it separately.

 

 

1: identifier

Variables, classes, and methods all need a certain name. We call this name an identifier. Java has certain limitations on identifiers. First, all identifiers must start with a letter (case-insensitive), underscore _, or dollar sign $; second, the identifier is a number (0-9 ), it is composed of uppercase letters of the A--Z, lowercase letters and underscores (_) of a -- Z, dollar signs ($), and ASCII code before the hexadecimal 0x0; third, note that the identifier cannot use the keywords retained by the system. The above are the basic rules for naming identifiers. The following is a forward and false comparison table, which provides a better understanding of the naming rules of identifiers:

Invalid legal identifier

Try try # (Note: # cannot be used as the identifier)

Group_7 group (Note: it cannot start with a number)

Opendoor open-door (Note: bottom-cannot be used as the symbol)

Boolean_1 Boolean (Note: Boolean is a keyword and cannot be used as a identifier)

 

 

2: keywords

 

The keyword is the identifier used by the Java language. It has its specific syntax meaning. All Java keywords cannot be used as identifiers. Java keywords include: 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 return, true, Char, final, interface, short, try, Class, finally, long, static, void, const, float, native, sup Er, while, etc.

 

 

3: Data Type

Java has different data types. Java has the following data types: integer, floating point, Boolean, complex, and string.

Integer Data is the most common data type. It is represented in decimal, hexadecimal, and octal. The hexadecimal integer must start with 0x. Each integer occupies a 32-bit storage space, that is, four bytes. This means that the range of integer data is between-2,147,483,648 and 2,147,483,648. For some reason, you must indicate a larger number, and the 64-bit long integer type should be sufficient. If you want to forcibly save an integer as a long, you can add the letter L after the number.

Floating point data is used to represent a decimal number. For example, 1.35 or 23.6. It is the standard format of floating point. It can also be used in scientific notation. The following are some examples: 3.1415926 0.34. 86. 01234 9.999e8

The standard floating point number is called a single-precision floating point number. Its storage space is 32 bits, that is, four bytes. There are also 64-bit double-precision floating point numbers. You can use the D suffix to determine whether you want to use this double-precision floating point number.

Boolean is the simplest data type. boolean data has only two States: true and false. The true and false statuses are usually represented by the true and false keywords.

Character data is a single character enclosed by a pair of single quotes. It can be any character in the character set, such as: & apos; A & apos;, & apos; B & apos ;.

String data types are character sequences enclosed by a pair of double quotation marks. String data is actually implemented by the string class (the concept of class will be explained in detail in subsequent sections ), instead of the character array used in C. Every string data will generate a new instance of the string class. Readers do not have to worry about the relationship between the string and the class concept. Due to the characteristics of the class, you do not have to worry about how to implement them, they take care of themselves. It should be noted that strings are used as classes in Java only for security considerations.

The following is an example of several strings.

 

"How are your" "I am student 4: operators in any language have their own operators. Java is no exception, such as +,-, *,/, and so on, the operator is used to form an expression with a certain amount of operational data to complete corresponding operations. Different operators are used for different data types.

 

 

5: delimiter

The Delimiter is used by the compiler to determine where the code is separated. '''''; '': 'Are the separators of the Java language.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.