Java Beginner day-02

Source: Internet
Author: User

The basic format of Java code: Java code must be stored in a class. Classes need to be defined using the Class keyword, which can be preceded by a modifier.

1 class {2         code block;              3 }

Key points of Java syntax:

1. Each execution statement must be followed by a (; semicolon)

2. The Java language is strictly case-sensitive

3, Code layout level clear

4, consecutive characters can not be two lines to write eg:

1 SYSTEM.OUT.PRINTFLN ("This is 2 wrong!" "); 3 // Java Compiler Error

Long characters available connection symbol ' + '

1  SYSTEM.OUT.PRINTFLN ("This is" +2  "wrong!) ");

Java notes: Single line//Note text multiline/* Note Encyclopaedia Word */Document Comment/** Note text */

Identifiers: Letters, Numbers, underscores (_) dollar sign ($) numbers cannot begin, and cannot have keywords. Defines the first letter of the class name capitalization. such as: Demo Rules: 1, package name all lowercase cn.itcast.test
2, Class name interface list of the first letter capital
3, the constant word capital, connect the word with underline
4, see the word know

Java keyword: lowercase, identifier cannot be keyword eg:class, public                                        

Classification of constants in Java
1. Integer constants, all integers
2. Decimal constants, all decimals
3. Boolean Type (Boolean): True False
4. Character constants, single quote ' ' logo
5. String constant, double quotation mark "" identifier
6.NULL constant, return value: null
Formal four forms of expression
1. Binary: 0,1
2. Eight binary: 0-7
3. Decimal: 0-9
4.16 binary: 0-9,a-f ox means beginning
Special characters: backslash \ Escape character
-\ r Enter, the cursor locates the beginning of the current line and does not jump to the next line
-\ n line-break,
-\ t Tab ==tab
-\b Backspace ==backspace

The concept of variables

A storage area in memory
The zone has its own name (variable name) and type (data type)
Data in this region can change over a uniform type
Why define variables: Constants that are used to keep a uniform type, and can be reused
Variable format: Data type variable name = initialization value

Force type to turn: byte B = 3;
b = (byte) (b+4);

Cast comparison:
System.out.println (' a ' + 1); 98
System.out.println ((char) (' a ' + 1)); B

Byte short char automatically promoted to int type

Test int Maximum Small value
int Max==int X=integer.max_value;
int Min==int X=integer.min_value;

Java Beginner day-02

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.