"Java Fundamentals" June 9

Source: Internet
Author: User

1. Java Comment: single-line comment, multiline comment, document comment

Document comments: Execute Javadoc, generate HTML-formatted code reports;

Multi-line annotations do not allow nesting.

2. Identifier naming specification

Package name: all words lowercase;

Class name Interface name: All words capitalized in the first letter;

Variable name and function name: The first word is lowercase and the first letter of each word is capitalized;

Constant name: All words capitalized, each word underlined ' _ ' connection.

Note: The keyword cannot be an identifier;

Keyword all letters lowercase.

3, negative number of binary: Take the reverse plus one

4. Data type

Basic data types: Byte, short, int (integer default), long, float, double (decimal default)

Char

Boolean

Reference data type: class, interface, []

Note: Data type conversions

 Short num = 9= num + 10;

Compile error, 10 default to int type, ' = ' data type inconsistent, need to cast

num = (short) (num + 10);

Attention:

 Short num = 9+ =  10;

The compilation was successful because it was converted automatically.

"Programing in Java" explains:

Q. is there any difference between a + = b and a = a + b, where a and b are PR Imitive types?

A. possibly, if A and b are of different types. The assignment statement A + = b is equivalent to a = (int.) (A + B) if a is of type I NT. Thus, if b is of type double, a + = b are legal, but a = a + b is a compile-time Error.

5. String connector, addition operator

Note: string data and any data are connected with ' + '

1  Public classHello2 {3      Public Static voidMain (string[] args)4     {5         intA = 4, B;6b = a++;7System.out.println ("a =" + A + ", B =" +b);8SYSTEM.OUT.PRINTLN ("AB =" + A +b);9System.out.println ("a + b =" + (A +b));Ten     } One}

6. Shift

>>: Fill the vacancy with the sign bit

>>>: with 0 fill vacancies

"Java Fundamentals" June 9

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.