Java Fundamentals 2-Basic syntax

Source: Internet
Author: User
Tags bitwise

1. Identifier: A sequence of characters used to name a class, interface, method, variable, etc.

Composition rules: English uppercase and lowercase letters, numeric characters, $ and _
Note: Cannot start with a number, cannot be a keyword in Java, is case-sensitive

2. Note: The text used to interpret the description program.
Note Classification format in Java: (1) Single-line Comment://(2) Multiline Comment:/* can't see Me */(3) document Comment:/** can't see me * *

3. Constant: Its value cannot be changed during program execution.

Constant classification: Literal constants, custom constants

Literal constants (1) string Constants "Hello" (2) Integer Constants 12,23 (3) Decimal Constants 12.34 (4) Character constants ' A ', ' a ', ' 0 ' (5) Boolean constant True,false (6) NULL constant NULL
4. Variable: The amount of the value that can change within a certain range during the execution of a program.

Variable definition Format: (1): Data type variable name = initialization value, (2): Data type variable name; Variable name = initialization value;

5. Data type and type conversion

(1) Java is a strongly typed language that provides the corresponding data types for each type of data.
(2) Category: A: Basic Data Type: 4 Class 8 kinds B: Reference data type: Class, interface, array.
(3) Basic data types
A: Integer occupies bytes byte 1 short 2 int 4 long 8 B: Floating-point number float 4 Double 8
C: Char 2 D: Boolean Boolean 1
Note: integers By default are of type int, and floating-point numbers are double by default.   Long integers to be added L or L. Single-precision floating-point numbers are added F or f.

6: Data type conversion
(1) Boolean type does not participate in conversions
(2) Default conversion
A: From small to large
B:byte,short,char--INT--long--float--double
C:byte,short,char do not convert each other, directly into the int type participates in the operation.
(3) Forced conversion
A: from big to small
B: There may be a loss of precision, generally not recommended for such use.
C: Format:
Target data type variable name = (target data type) (converted data);

7. Operators

Precedence of operators (high-to-low)

Priority level

Describe

Operator

1

Brackets

(),[]

2

PLUS sign

+,-

3

auto-subtract, non

++ , --, !

4

multiplication, taking surplus

*,/,%

5

Add and Subtract

+,-

6

shift operation

<< , >> , >>>

7

size relationship

> , >= , < , <=

8

Equality relationship

= =,!=

9

Bitwise-AND

&

10

Bitwise XOR OR

^

11

Bitwise OR

|

12

Logic and

&&

13

Logical OR

||

14

conditional operations

15

Assignment operation

= , += , -= , *= , /= , %=

16

Bit assignment operations

&=,|=,<<=,>>=,>>>=

8. Keywords

Abstrac indicates that a class or member method has an abstract property Assert assertion, which is used for program debugging One of the Boolean basic data types, Boolean type Break jumps out of a block early One of the byte base data types, byte type
Case is used in a switch statement to indicate one of the branches Catch is used in exception handling to catch exceptions Char one of the basic data types, character type Class declares a category

Const

Reserved keywords, no specific meaning

Continue

Back to the beginning of a block

Default

Default, for example, used in a switch statement

, indicates a default branch

Do

Used in the DO-WHILE loop structure

Double

One of the basic data types, double-precision floating-point number types

Else

Used in a conditional statement to indicate a branch when the condition is not true

Enum

Enumeration

Extends

Indicates that one type is another type of

subtypes, where common types have classes and interfaces

Final

Used to describe the final attribute, indicating that a class cannot

A subclass is derived, or the member method cannot be overwritten

The value of the member domain cannot be changed,

Used to define constants

Finally

Used to handle exception cases, to declare a block of statements that are essentially bound to be executed

Float

One of the basic data types, single-precision floating-point number types

For

A guide word for a cyclic structure

Goto

Reserved keywords, no specific meaning

If

Guide Words for conditional statements

Implements

Indicates that a class implements the given interface

Import

Indicates that you want to access the specified class or package

instanceof

Used to test whether an object

is an instance object of the specified type

Int

One of the basic data types, integer type

Interface

Interface

Long

One of the basic data types, long integer type

Native

Used to declare a method that is implemented by a computer-related language (such as the C/c++/fortran language)

New

Used to create a new instance object

Package

Package

Private

An access control method: Private mode

Protected

An access control method: Protection mode

Public

An access control method: Common mode

Return

Returning data from member methods

Strictfp

Used to declare fp_strict (single-precision or double-precision floating-point numbers)

Expression follows IEEE 754 arithmetic specification

Short

One of the basic data types, the short integer type

Static

Indicates a static property

Super

Indicates a reference to the parent type of the current object or a constructor for the parent type

Switch

Guide words for Branching statement structures

Synchronized

Indicates that a piece of code needs to be executed synchronously

This

Reference to the current instance object

Throw

Throws an exception

Throws

Declares all exceptions that need to be thrown in the currently defined member method

Transient

Declaring a member domain without serialization

Try

Try a block that might throw an exception

void

Declares that the current member method does not return a value

Volatile

Indicates that two or more variables must be changed in a synchronized manner

While

Used in the loop structure

                                                                                                      

Author: luvsangiin Source: http://www.cnblogs.com/eeddee/p/8721871.html

Copyright: This article copyright belongs to the author and the blog Garden has a welcome reprint, reprint please indicate the source of the blog.

Java Fundamentals 2-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.