Java Basic syntax

Source: Internet
Author: User

1. Keywords

access Control : Private (privately) protected public (common)

class , method and variable modifiers : Abstract class extends final implements interface native new static STRICTFP synchronized Transient Vol Atile

Program Control: Break continue return does while if-else for instanceof switch case default

error handling : Try cathc throw throws

packet-related : Import package base type: Boolean byte char double float int long short null true false

variable reference : Super this void

reserved words : Goto const

2. identifiers

2.1 definition

1:java a sequence of characters, called identifiers, is used when naming features such as variables, methods, and classes.

2: As long as it is possible to name the place is called the identifier.

2.2 legal definition of identifiers

1: Written by 26 English letters, number 0-9, symbol: _ or $ composition.

2: Numbers can not begin.

4:java are strictly case-sensitive and have unlimited lengths.

5: Identifiers do not contain spaces.

2.3 Java Name Naming conventions

1: Package Name: All letters are lowercase when multiple words are composed. such as: xxxyyyzzz

2: Constant Name: All letters are capitalized, and multiple words are joined with underscores. Xxx_yyy_zzz

3: Class name Interface name: Multi-word composition is all the first letter capitalized. Hump writing: XXXYYYZZZ 4: Variable name and function name: When multiple words are composed, the first letter is lowercase, and then the first letter of the word is capitalized. Xxxyyyzzz

3. Notes

1, single-line (single-line) Comment: "//..."

2. Block comment: "/*......*/"

3. Document Comment: "/**......*/"

4. Javadoc annotation Tag syntax

@author description of the class indicates the author of the development of such a module

@version the description of the class indicates the version of the class module

@see a reference to the description of classes, properties, methods, and related topics

Description of a parameter in a method @param description of the method

Description of the method return value @return The description of the method

@exception the description of the method, describe the exceptions that the method might throw

4. Constants

? Constant indicates a value that cannot be changed

? Categories of Constants in Java:

1. Integer constants. All integers

2. Decimal constants. All decimals

3. Boolean constants. More unique, only two values. True False

4. Character constants. Identifies a numeric letter or symbol with a single quotation mark (' ')

5. String constants. Identify one or more characters in double quotation marks

6. NULL constant. There is only one value: null

? For integers: Java has four forms of representation

1. Binary

2. Decimal

3. Eight binary: 0-7, full 8 into 1, denoted by the beginning of 0.

4.16 binary: 0-9,a-f, full 16 in 1, beginning with 0x.

5. Negative number binary representation

Small rule: The highest number of negative numbers is 1, the original numbers are reversed and added 1

Java Basic syntax

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.