Java Basics (Review)

Source: Internet
Author: User

Java Foundation Composition:

keywords--identifiers--annotations--Constants & Variables--operators--statements--functions--arrays


keyword features: letters are all lowercase
Eg: basic data type: int byte long short float double
Character type: Char
Boolean: Boolean (True/false)
Reference data type: class interface void
Process Control: if () {}else{}
Switch () {
Case:
Break
Defualt:
}
Loop while doing () while for
Break jumps out continue continue return returns
Access rights: Private, public, protected
Defined:
Abstract final static synchronized (synchronous) enum (enum)


Extends implements

New This super instanceof (Judge object type)
Exception handling:
Try Catch finally
Throw (thrown by instantiation of an exception in a program)
Throws (identifies method throw exception)
Package: Package Import
Other: Native (local)
STRICTFP (Strict float point (exact floating-point))
Transient (variable modifier, which declares an instance variable that is not serialized when the object is serialized)
Volatile (type modifier, used to modify variables that are accessed and modified by different threads)

ASSERT (assertion, which can be considered a high-level form of exception handling, is used to capture the assumptions we make in our code)


identifiers


Some of the names that are customized in the program are made up of uppercase and lowercase [a-za-z], numbers [0-9], underscores [_], special characters [$].
Comments: Single-multirow-document comments
(Single-line comment)

/*
(Multiline comment)
*/

/**
(Document comment)
@author author
@version version number

*/


Constants
Immutable values
Variable
Storage of uncertain data, that is, the need to open up a space in memory
1. Initialization of variables:

(1) Java variables defined in the method are not automatically initialized and must be initialized before it can be used.
(2) variables defined in the class are automatically initialized.


Operator

+-*/% + +--+ = = (a+=4>>a=a+4) = (opposite) > <= ...


& with | or ^ xor or (True^true = False True^false = True opposite =true same =false)


。 Non-&& short circuit and | | Short-circuit or (when the left is true, the right does not operate because the result must be true to the left of false, right to participate in the operation.) )


The

* bitwise operator is the operator of a binary operation, and "bit" is the binary bit, the fastest operation, but the limit is based on 2. << Left  3<<2 = 3*2^2=12
>> right Shift  3>>1 = 3/2^1 = 1
>>> unsigned right shift 3>>1 = 3/2^ 1 = 1
& and Operations 6 & 3 = 2
| or operation 6 | 3 = 7
^ Xor/op 6 ^ 3 = 5
~ anti-code ~6 =-7


* ternary operator:

(conditional expression) 。 Expression 1: expression 2; => must have a result

(1) If the condition is true, the result of the operation is an expression 1; 
(2) If the condition is false, the result of the operation is the expression 2;

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.