Java Learning Series (ii) Java annotations, identifiers, basic data types, and error-prone points for conversion

Source: Internet
Author: User

I saw a joke today and shared it with you. A couple cuddling up in the park with sweetness. When the man sees the female's hair so soft, he can't help but feel it. The lady's delicate Didi said, "Sorry! Annoying !" After hearing the itch, the man sneaked Another touch and said, "Well, no !" As soon as the man heard it, his heart was about to fly and touched it again. Suddenly the woman stood up and said rudely, "don't touch it! My wigs are almost lost !!! Java annotations we have discussed the Java operating mechanism, JDK installation configuration, and other related operations. Today we will start with Java annotations. Java annotations have no impact on the program itself, mainly because developers provide some auxiliary information for better understanding. Java annotations include single lines, multiple lines, and document annotations. Single line: // The content following the comment is a single line; multiple lines:/* the middle part is a multi-line comment */; as for document comment, we take a simple Java Applet as an example.

/** Here is the document comment. We can use the javadoc command to extract the document comment directly and generate the API document */public class $ moon cake {// here is a single line comment. Main method (program entry) public static void main (String [] args) {System. out. println ("Wuren moon cake tastes really good! ");}/* Public void info () {System. out. println (" this method is commented out by multiple lines .. ");}*/}

 

In this case, if we want to use javadoc to generate API documentation, commands, and running effects such as: Open index.html in the myfirstapidirectory, you will find the powerful javadoc command. Java identifier (legal name): Class Name, method name, etc. It can start with Chinese characters, USD $, but cannot start with a number, and cannot be a Java keyword or reserved word (both must be in lower case ). Direct quantity: true, false, null. There are a total of 53 keywords, two of which are reserved words: const and goto. They are not used in Java currently, so they are meaningless. The above class name can be compiled as $ moon cake, but it is generally not written in this way. Our class name should be meaningful as much as possible and be visible to others. The basic data type Java language is a strong-type language. All variables (the data in the computer memory needs to be accessed through variables, and the variables are the access method of a piece of memory) must first declare the type, use again. Java has eight basic types: integer value range:-128 ~ 127-32768 ~ 32767-2 GB ~ 2G-1-2 power 63 ~ 63 to the power of 2-14 integers (decimal places not supported): byte (1 byte), short (2 byte), int (4 byte), long (8 byte) two floating point types (decimal supported): float (4 bytes), double (8 bytes), one character type: char (2 bytes), and one boolean type: boolean (1 byte) there are only two values: true and false. When we use an integer directly, the integer is of the int type by default. If you want to use a long type, add L or l after a positive number. Java has three forms of Integer constants: 1. decimal integers, such as 123,-456,0. 2. an octal integer starting with 0. For example, 0123 indicates the decimal number 83 and-011 indicates the decimal number-9. 3. A hexadecimal integer starting with 0x or 0X. For example, 0x123 indicates the decimal number 291, and-0X12 indicates the decimal number-18. When we use a floating point directly, the floating point is of the double type by default. If you want to use a float type, you should add F or f after a positive number, for example, floating point :. 512f (the integer 0 can be omitted, expressed in 10 decimal format); 0.12e4F (4 power of 0.12 multiplied by 10, scientific Notation ). In actual programming, try to use double (large range, high accuracy ). Character Type: each character type variable can contain only one character. It can be in English or Chinese. For example, 'Q', '中', escape characters: '\ n',' \ t', '\ R', and' \ B. Therefore, when assigning values to variables, you must pay attention to the value range of the variables. It should be added that all positive infinity and negative infinity are equal, respectively. Non-number (NaN) is 0.0/0, and non-number is not equal to itself.

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.