"Crazy Java Handout" (v)----data types

Source: Internet
Author: User

A note

Single-line Comment://

Multiline Comment:/* */

Document Note:/**

*/

Because only public or protected-modified content is what you want to expose to others, and the API documentation primarily provides information to the consumer, JAVADAOC only handles public or protected-modified content by default. If the developer really wants the Javadoc tool to extract the contents of the private adornment, you can add the-private option when using the Javadoc tool.

The Javadoc tool does not extract information from the @author and @version two tags by default, and if necessary, you should specify-author and-version two options when using the Javadoc tool.

Two data types

    • Base type (primitive type):
      1. Boolean type 1-bit
      2.     numeric type:
        1. integer   Type (default integer is int)
          1. byte 1 byte    -2^7 ~ 2^7-1
          2.       short   2 bytes   -2^15 ~ 2^15-1
          3.       int         4 bytes   -2^ ~ 2^31-1
          4.       long       8 bytes   -2^63 ~ 2^63-1
          5.       Char       2-byte
        2.       floating-point type (default floating-point number is double)
          1. float       4 bytes (the 1th bit is the sign bit, the next 8 bits represent the exponent, and the next 2 bits indicate the mantissa)
          2.      D Ouble    8 bytes   (The 1th bit is the sign bit, the next 11 bits represent the exponent, then the next 52 bits represent the mantissa)
    • Reference type (reference type):
      1. Class
      2. Interface
      3. Array
      4. Null
    • binary integers

The computer saves all integers in the form of a complement. Complement calculation rule: positive complement and the original code is exactly the same, negative complement is its anti-code plus one, anti-code is to the original code bitwise reverse, but the highest bit (sign bit) remains unchanged.

    • Infinity

Positive Infinity: double.positive_infinity or Float.positive_infinity

Negative Infinity: double.negative_infinity or Float.negative_infinity

Non-number: Double.NaN or Float.nan

    

All positive infinity values are equal, all negative infinity values are equal, and Nan is not equal to any numeric value, even to Nan.

Only the floating-point number divided by 0 can get positive infinity and negative infinity, because Java automatically treats divisor 0 as 0.0. However, if an integer value is divided by 0, an exception is thrown: java.lang.ArithmeticException:/by zero

eg

 Public classTestDate { Public Static voidMain (string[] args) {/** Date date = new Date (1474496229424L);         SYSTEM.OUT.PRINTLN (date); */        floatAF = 5.2345556f;        SYSTEM.OUT.PRINTLN (AF); DoubleA = 0.0; Doublec =double.negative_infinity; floatD =float.negative_infinity; System.out.println (c==d); System.out.println (A/a); System.out.println (A/A = =Float.nan); System.out.println (6.0/0 = = 555.0/0); System.out.println (-8/a); System.out.println (0/0); }}

Output Result:

5.2345557
True
NaN
False
True
-infinity
Exception in thread "main" java.lang.ArithmeticException:/By zero
At Com.citi.icg.portal.resource.service.impl.TestDate.main (testdate.java:22)

    • Java7 using underscores in new values

By using underscores to separate values, you can more visually distinguish how many bits are contained in a numeric constant.

    

  

"Crazy Java Handout" (v)----data types

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.