In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to parse Java data type syntax, the content of the article is of high quality, so Xiaobian shares it with you as a reference, I hope you have a certain understanding of relevant knowledge after reading this article.
Many programming languages depend on specific computer types and specific compiled implementations of Java data type attributes, such as word and integerJava data type sizes. Java's virtual machine, on the other hand, is responsible for defining aspects of its built-in Java data types.
Java data types in detail
Java data types are abstract representations of memory locations. Programmers can take advantage of a variety of Java data types: some defined by the programming language, some defined by external libraries, and some defined by the programmer. Many programming languages depend on specific computer types and specific compiled implementations of Java data type attributes, such as word and integerJava data type sizes. Java's virtual machine, on the other hand, is responsible for defining aspects of its built-in Java data types. This means that no matter what low-level operating system the Java Virtual Machine (JVM) runs on, the properties of Java data types are exactly the same.
Simple Java data types
Simple Java data types are built-in Java data types that can't be simplified any more, defined by the programming language to represent real numbers, characters, and integers. Larger, more complex Java data types can be defined in combinations of simple Java data types. In most cases, simple Java data types have their hardware equivalents. For example, int simple types are sometimes stored in 32-bit hardware registers. Java provides several classes of simple Java data types to represent numbers and characters.
Simple Java data types are generally divided into the following categories: real, integer, character, and boolean. These categories contain a number of simple types. For example, Java defines two simple types: float and double, both of which belong to the class of real numbers, and four simple types: byte, short, int, and long, all of which belong to the class of integers. There is also a simple type char which is classified as a character type. Boolean classes have only one simple type: boolean. Table A details Java's simple Java data types.
Table AJava Simple Java data types
Simple Type Size Range/Precision
float4 bytes 32 bits IEEE754 single precision
double8 byte 64 bit IEEE754 double precision
byte1 byte-128 to 127
short2 bytes-32,768 to 32,767
int4 bytes-2,147,483,648 to 2,147,483,647
long8 bytes-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
char2 bytes The entire Unicode character set
boolean1 bit True or False
Java Simple Java Data Types
All numeric variables in Java are signed, and Java does not allow arbitrary conversions between Java data types. Only numeric variables can be type-converted. For example, boolean cannot be converted to other Java data types, and other Java data types cannot be converted to boolean.
Because Java's simple Java data types are well defined and direct memory access is not allowed, the sizeof operator is eliminated from the Java language.
Java's simple Java data types are not objects. In order to take an object-oriented approach to Java simple Java data types, you first need to encapsulate them in classes.
wrapper classes
Java also provides built-in wrapper classes such as Byte, Short, Boolean, Character, Integer, Double, Float, and Long. These wrapper classes provide intuitive, practical methods. For example, the Byte, Float,Integer, Long, and Double classes all have a doubleValue() method that converts values stored in instances of the class to Double types. Also, all wrapper classes provide static valueOf(Strings) methods that convert a given String to its corresponding simple type. The code in Listing A demonstrates some of the uses of these wrapper classes.
Simple Java data type initialization
In the Java language, simple Java data types are automatically initialized to default values when declared as member variables of classes, unless explicitly declared. Declaring a local variable for a method with a simple Java data type does not automatically initialize and causes the compiler to throw error messages like "Variablelex may not have been initialized. (x variable not initialized)"Table B defines default values for Java Simple Java data types.
Table BJava Default values for simple Java data types
type defaults
boolean:false
Byte:0
short:0
int:0
Long:0
Char:´u0000´
Float:0.0
double:0.0
Java Simple Java default initializers for data types
The code in Listing B shows that all Java simple Java data types are used as member variables of the Initialization class. The example also shows that an int variable is declared locally in the constructor of the Initialization class. Without modifying the above code, the compiler will throw errors when compiling the above code.
Once the lines of code that cause the problem (those that reference uninitialized variables causing the error) are deleted or commented out. After successful compilation and execution of the program, the following results will be displayed:
byte:0 short:0 int:0 long:0 float:0.0 double:0.0 char:0 boolean:false
We can also explicitly initialize member variables to other values, as shown in the following code:
byteb=5; shorts=123; inti=1234; longl=12345; floatf=123.45f; doubled=12345.678; charc=´A´; booleanz=true;
Java defines a full set of simple Java data types. In addition, Java removes hardware and compiler dependencies from other programming languages, allowing programmers to turn their attention to other problems.
About how to parse Java data type syntax to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.