1. There can be only one public class in a Java class file
Java programs are performed from the main function of the public class, and only one public class is available to facilitate the class loader. Each compilation unit can have only one public class. Because each compilation unit can have only one public interface, it behaves as a common class. The interface can include many classes that support package access, as required. If there is more than one public class, the compiler will error, and the public class name must be the same as the filename.
2. Change the return value in the main () method from void to int, and the program cannot be compiled and run.
The main function cannot be called, so there is no return value. Void has no return value, and void is changed to int, there must be a return value, so there is a compilation error.
, there will be an error message,
3.java variable follows "Masking principle of variable with the same name"
, the debug result is 2.
Each variable has a "valid" area, and the out-of-zone variable is no longer valid. Java follows the masking principle of a variable of the same name, a private static variable value=1 is defined in the class, a value=2 is defined in the function, a value is output in the function, and the result is 2. If value is not defined in the function, the output is 1.
Type conversions in 4.java
Basic data type conversions in Java are divided into automatic type conversions and forced type conversions. Automatic data type conversions are variables that are assigned high priority by data with low priority. Forcing a type conversion is a variable with a high priority value assigned to a low priority. Forcing type conversions usually has a loss of storage precision. When converting between integers, the numeric value does not change, while converting an integer type, especially a larger integer type, to a decimal type may result in a loss of precision due to different storage methods.
(1) Basic integral type Int:4 byte 32 bit, numeric range 2147483648 to 2147483648
(2) byte-type byte:1 byte 8-bit, numeric range 128 to 127
(3) Short integer short:2 byte 16 bit, value range is 32768 to 32768
(4) Long integer long:8 byte 64 bit, value range is 9233372036854477808 to 9233372036854477808
(5) Character type Char:2 byte 16 bit, value range is ' \u0000-u\ffff '
(6) Boolean Boolean:1 byte 8 bit, value range is True/false
5. On the accuracy of numerical operations on double type
0.01+0.05=0.06000000000000005; It is clear that the result is inaccurate.
A value of type double takes 64bit, or 64 binary numbers, except that the highest bit represents the positive and negative sign, and the lowest bit is bound to have an error with the actual data (unless the actual data is exactly 2 of the n-th square).
6. Hands-on brain
The + of the first output statement is the connection of x and Y, and the result of the calculation connects the two data together;
The second output statement, + is the operator, sums X and Y.
Basic Java language Issues