1, the necessary basic knowledge of Java? Int basic type
First of all, Java integers are 32-bit signed (that is, positive integers and negative integers), which are represented by int keywords:
int some number = 10;
Of course, like all basic types, integers have their limitations. Because it has only 32 bits, its value is between -2 147483648 and 2 14743647. This is a big number! Of course, we can use the following techniques to confirm this in the DrJava interactive panel:
MAX_VALUE // Prints 2,147,483,647 integers. MIN_VALUE // Print -2, 147,483,648
Of course, int is the most commonly used integer type in simple calculation. If you need a wider range of numbers, please refer to the length below.
2. Essential basic knowledge of Java? Two basic types
Unlike int, Java's double type is a 64-bit floating-point number, which is represented by the double keyword:
double some number = 1 10.55;
It should be noted that floating-point numbers are actually real numbers. In other words, a double-precision floating-point number contains a decimal point.
Because the double type is 64-bit, it can represent more numbers than integers. Similarly, we can use the interactive panel to confirm the range of double precision types:
Double it. Max _ value/1.7991348 623157e308 double printing.
It should be noted that the negative exponent represents a very small number, not a very large negative number. So the range of values here is not exactly the same as that of integers.
Generally speaking, double is the default choice for using floating-point numbers in Java. Another option is a floating exchange rate.
3. Essential basic knowledge of Java? Carbon base type
As we can see, the character type in Java represents 16 characters, which is represented by the char keyword:
Char someCharacter = ' f
All characters in Java are represented by single quotation marks. In addition, double quotation marks are used to represent strings. We'll talk about strings later. (page)
As usual, we can find the range of characters by the following code:
Character. MAX_VALUE / / print '?' Characters. MIN _ VALUE// print?
To make this range meaningful, we can convert the result into an integer (more on this later):
(integer) characters. Output 65535(int) characters. Minimum value//Output 0
As you can see, the char type is the only unsigned type in Java. In other words, the values of characters range from 0 to 65535, and each value is mapped to a specific character. If you need to create characters outside this range, you can combine a pair of characters.
4. Essential basic knowledge of Java? Byte basic type
When we talk about binary, we are actually talking about the concept of bits. Bytes are composed of 8 bits, and bytes are one of the basic types supported by Java. In fact, the byte type is nothing more than an 8-bit integer, with values ranging from-128 to 127. As you can guess, bytes are represented by the byte keyword:
someByte = 20
Similarly, you can use the following code snippet to confirm the range of byte types:
Byte output 127 bytes. Min_value // Print - 128
According to my experience, byte types are very useful when reading and processing raw data. But generally speaking, we won't use it because the scope is too small.
What are the basic knowledge of Java? If you want to learn this language well, you must know it. Bian Xiao of Global Network School hopes that when you start programming, you can learn Java first, which can optimize your working thinking. Bian Xiao wishes you a pleasant journey to Java. If you want to know more about Java, you can click on other articles on this website to learn.