Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic composition of the Java language

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you what is the basic composition of the Java language, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The Java language mainly consists of the following five elements: identifiers, keywords, text, operators, and delimiters. These five elements have different grammatical meanings and composition rules, and they cooperate with each other to complete the semantic expression of Java language. Let's explain it separately below.

1: identifier

Variables, classes, and methods all require certain names, which we call identifiers. There are certain restrictions on identifiers in Java. First of all: the first character of all identifiers must be letters (uppercase and lowercase), underscore _ or dollar symbol ¥; secondly, the identifier is made up of numbers (0melo9), all uppercase letters from Amuri Z, lowercase letters and underscores from Amurz, dollar character ¥and all ASCII codes before hexadecimal 0xc0; and the third note that the indicator cannot be marked with keywords reserved by the system.

The above are the basic rules of identifier naming, the following is a correct and error comparison table, through which you will have a better understanding of the naming rules of identifiers:

Legal identifier illegal identifier

Try try# (Note: you can't use # as an identifier)

Group_7 7group (Note: cannot start with a numeric symbol)

Opendoor open-door (Note: cannot be used as a marker)

Boolean_1 boolean (Note: boolean is a keyword and cannot be marked with a keyword)

2: keyword

Keywords are identifiers used by the Java language itself and have specific grammatical meanings. All Java keywords will not be used as identifiers. The keywords for Java 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 return, true, char, final, final, interface, short, try, class,

3: data type

Java has different data types. The data types of Java are: integer, floating point, Boolean, character, string.

Integer data is the most common data type, which is represented by decimal, hexadecimal, and octal. Hexadecimal integers must start with 0X.

Each integer data occupies 32 bits of storage space, or four bytes. This means that the range represented by integer data is between-2147483648 and 2147483648, and if for some reason you have to represent a larger number, 64-bit long integers should be sufficient. If you want to force an integer into a long, you can add the letter l after the number.

Floating-point data is used to represent a decimal number with a decimal. For example, 1.35 or 23.6. Is the standard form of floating-point numbers, and can also be used in the form of scientific enumeration. here are some examples:

3.1415926 0.34. 86. 01234 999.9 million

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

Boolean type is the simplest data type. Boolean data has only two states: true and false, which are usually represented by the keywords true and false.

Character data is a single character enclosed by a pair of single quotation marks. It can be any character in the character set, such as'a','b'.

The string data type is a sequence of characters enclosed in a pair of double quotes, and the string data is actually implemented by the String class (the concept of which we will explain in more detail in later chapters), rather than the character array used in the C language. Each string data will produce a new instance of the String class, readers do not have to worry about the relationship between the string and the concept of class, because of the characteristics of the class, you do not have to worry about how to implement them, they will take care of themselves, it is important to note that the string in Java as a class is only for security reasons.

Here are a few examples of strings

"How are your"

"I am Student

4: operator

Any language has its own operator, Java language is no exception, such as +, -, *, / and so on are operators, the function of the operator is to form an expression with certain operation data to complete the corresponding operation. There are different operators for different data types.

5: delimiter

The delimiter is used to make the compiler confirm where the code is separated.' ;': 'are delimiters for the Java language.

These are all the contents of the article "what is the basic composition of the Java language?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report