I do not know whether the Java simple data types are understood, the following Java five types of simple data types to represent numbers and characters, for detailed explanation and analysis.
First, simple data type initialization
In the Java language, a simple data type is automatically initialized to the default value when declared as a member variable of a class, unless explicitly declared. A simple data type that declares a local variable for a method is not automatically initialized and causes the compiler to throw an error message similar to the following "Variable X may not have been initialized." (x variable not initialized) "Table B defines the default values for Java simple data types.
Second, the package class
1ava also provides built-in encapsulation classes such as Byte, short, Boolean, Character, Integer, Double, float, and long. These encapsulation (wrapper) classes provide a very intuitive and practical approach. For example, Byte, Float, Integer, long, and double have the Doublevalue () method, which converts the value stored in an instance of a class to a double type. Also, all encapsulation classes provide a static valueof (string s) method to take a given string.
Iii. Types of data
The data type is the abstract expression of the memory location. Programmers can take advantage of a variety of data types: some are defined by programming languages, some are defined by external libraries, and others are defined by programmers. Many programming languages rely on specific computer types and specific compilation implementations of data type attributes, such as the size of Word and integer data types. Java virtual machines, on the other hand, are responsible for defining the various aspects of their built-in data types. This means that regardless of what low-level operating system the Java Virtual Machine (JVM) is running on, the properties of the data type are identical.
Default initial values for Java simple data types
The code in Listing B shows that all Java simple data types are used as member variables for 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 throws an error when compiling the above code.
Once the line of code that raised the problem, the code that referred to the uninitialized variable that caused the error to occur, was deleted or commented out.
Summary: Java defines a complete set of simple data types. In addition, Java removes other hardware and compiler dependencies into the language, allowing programmers to turn their attention to other issues. In the next article, we'll continue to discuss some of the most frequently used, Java-defined complex data types and see how they can be leveraged to deal with typical programming problems.
Five, Java simple data types
All numeric variables in Java are signed, and Java does not allow arbitrary conversions between data types. Only type conversions can be made between numeric variables. For example, a Boolean cannot be converted to another data type, and other data types cannot be converted to Boolean. Because Java's simple data types are precisely defined, and direct memory access is not allowed, the sizeof operator is canceled in the Java language. Java's simple data type is not an object. To treat Java simple data types in an object-oriented way, you need to encapsulate them first with classes.
The above five types of Java data type resolution is small to share all the content of the whole, hope to give you a reference, but also hope that we support cloud habitat community.