Chapter III Java's BASIC programming structure a simple Java application
- Access modifier public,private,protected
- The main method must be public-decorated, and C # does not have to
Data type
- Floating-point numbers can be represented in 16 binary
- Integers can be represented in 2,8,16 notation
- Double.positive_infinity,double.negative_infinity,double. NaN indicates positive infinity, negative infinity, not numerical value; if (X==double.nan) is never established, you can use Double.isnan (x) to determine
- It is strongly recommended that you do not use char in your program unless you have to use string instead
Operator
- Integers are thrown by 0 except for exceptions, and floating-point numbers get infinite or Nan results
- The initial JVM's calculation of floating-point rules must be truncated so that consistent results can be achieved on different types of machines, but later this is modified, and the JVM designer allows the intermediate results to be extended precision. However, methods/classes that have been STRICTFP modified must be truncated. The use of STRICTFP may produce overflow, but it is not a big problem.
- Math.floormod is to solve the problem of integer remainder, that is, the remainder of negative numbers in computer design is caused by negative numbers.
- The Strictmath class provides more accurate and predictable results than math
- int x; x+=3.5; is legal, the result is (int) (x+3.5)
String
- StringBuilder and StringBuffer API is the same, the difference is that StringBuffer is thread-safe, but the use of StringBuilder efficiency is high;
Process Control Statements
-
The for detects two floating-point numbers that require extra care, for (double x = 0; x = 0.1) may never end, because 0.1 cannot be accurately represented in binary
-
Java allows a tagged break statement, which can be used to jump to the beginning of a nested loop
Array
- The arrays.copyof () method is used for array copies, copying each element of the original array to a new array, usually for array expansion
Chapter III Java's BASIC programming structure