Chapter III Java's BASIC programming structure

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.