Java Review-language Basics

Source: Internet
Author: User

Basic Concepts

1. Identifier: consists of letters, underscores, numbers, dollar signs, but cannot start with a number.

2, Keywords: 50 keywords, goto Although does not exist, but still is the keyword

3, Variable: its naming specification is not necessarily according to the identifier, it can be Chinese and so on


Data Type

1, Java A total of 8 native data types (another is reference type), can be divided into four groups

1) Logic Type: Boolean

2) Character type: Char

3) Floating-point type: float, double

4) Integer type: byte short int long

2, data type precision sorting:

BYTE (1), short (2), char (2), int (4), Long (8), float (4), double (8)


operator

1, operators include: arithmetic operators, relational operators, assignment operators, bitwise operators

2, the use of break, he does not jump out of the code block, but jump out of a loop, no loop, then break no meaning!

3, the use of continue, can be transferred to the specified location, but this rarely used, is generally out of the outer loop of the outside!

4, the use of instanceof, this is a good operator, learn to use.


Special Matters

1. When there are several types of variables to be operated on, the type of the result should be the one with the highest precision in those variables (the largest data type of the range).

2. The operation of the coercion type conversion takes precedence over the arithmetic operator.

3, the result of modulo operation, that is, the remainder, his symbol is always consistent with the divisor.


For and Switch

1, switch switch statement, can receive the types are: byte short int char enumeration, JDK7.0 support string

2, for (;;) is a dead loop; the for (:) loop is the JDK5 property


access Rights

1, public: Common type, class inside, same package, sub-class, any situation can be called;

2, Protected: protection type, within the class, in the same package, for different packages of the subclass of the call can only be a subclass of a variable to be called. For example, the Super class has a protected attribute name, and this time son inherits from him, but son and super are not in the same package, this time if using:

Son son = new son (); Son.name; Compiled by

Super son = new son (); son.name;//compilation does not pass, property is not visible

Super son = new super (); son.name;//compilation does not pass, property is not visible

3, friendly type (default), can only be within the class and the same package call;

4, Private: can only be called within the class.


Java Review-language Basics

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.