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 are Java identifiers, keywords and data types

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

Share

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

This article mainly explains the "Java identifiers, keywords and data types", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Java identifiers, keywords and data types" bar!

Java identifier

";", "{}", "" in Java code

Java statements are separated by semicolons, Java code blocks are enclosed in curly braces, and spaces are ignored. Java identifier

1) the naming convention classes used to name classes, methods, and variables, and packages that follow JAVA, begin with an uppercase letter for each word. The letters of methods and variables are not capitalized, but everything else is business as usual.

2) can only start with a character, "_" or "$"

3) there is no length limit.

Java keyword

Goto and const are no longer used in java but still exist as keywords

There is no sizeof keyword in java. Values of type boolean in java can only use true and false, and these two values are also keywords.

There is no unsigned keyword in the java language (unsigned)

Java data type

1) Integer

Byte 1 byte 8 bits-128to127s

Short2 byte 16 bits-2 ^ 15 to 2 ^ 15-1

Int 4 byte 32 bits-2 ^ 31 to 2 ^ 31-1

Long 8 byte 64 bit-2 ^ 63 to 2 ^ 63-1

2) floating point type

Float4 byte 32 bit

Double 8 bytes 64 bit

3) character type

Char 2 bytes 16 bit

4) Boolean type

Boolean false/true

Note: 1) char is an unsigned 16-bit integer and the literal value must be enclosed in single quotation marks;'a'

2) String is a class, not a primitive data type

3) long integer numbers have a suffix of "L" or "l", octal prefix of "0", and hexadecimal prefix of "0x"

4) the floating point type is recognized as double

5) the float data type has a suffix "f" or "F", and the Double data type can be followed by the suffix "D" or "d"

6) char types can also use universal translated characters, but not ASCII codes. The format "\ u0000" can be used because unicode encoding is used in the char type.

Note: the integer value is stored, the positive number stores the original code (binary code), and the negative number stores the complement code (the original code takes the last bit plus one according to the bit).

Note: real values lose precision when they are stored, so do not compare two real values directly. The default real type of the system is the flexible type. When you want to use it, you need to add an f to the data, or force the conversion. A strong turn (a type with a large number of bytes goes to a type with a small number of bytes) discards the high value and takes only the low value.

The digital data type disaster reduction in java can be converted automatically from the type with a small number of bytes to the type with a large number of bytes, otherwise it needs to be converted forcefully, and the char type and int type can be converted into each other. Char and short cannot be converted like households.

Note: implicit type conversion

An operator b, if any one of apeny b is float type, the result of the previous operation is float type, if any one of apenience b is float type, if any one of arecore b is long type, the result of previous operation is long type, if there is no double, float, long type in aline b, then the result is int type.

In JDK, all basic data types are allocated space in advance when they are used, and only exist in the space themselves. When passed, it is a value pass, not a reference pass.

Methods defined in the class can be called in the main method by adding a static modifier before the return value. If you don't use static, you need to create an object in the main method and use the object to call the object's method.

Public class Test {public static void main (String [] args) {Test t=new Test (); int bread1; int Cobb 2; int [] a=new int [10]; t.sqort (a); add (bmam c)} public int [] sqort (int [] a) {. } static int add (BBM C) {. }} Thank you for your reading, the above is the content of "Java identifiers, keywords and data types". After the study of this article, I believe you have a deeper understanding of what Java identifiers, keywords and data types have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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