Java Basic Learning (i)---syntax

Source: Internet
Author: User

1: Keywords (words that are given a specific meaning by the Java language)

(1) Features: all lowercase.
(2) Precautions:
A:goto and const exist as reserved words.
B: High-level notebooks like notepad++ have special color tags on keywords

2: identifier (name of the variable method class, etc.)
(1) Composition rule: A: English case letter B: Digital c:$ and _

(2) Precautions: A: Cannot start with a number B: cannot be a keyword in Java C: case-sensitive

         (3) Common naming conventions (see Name and meaning)
                                a: Package   All lowercase                                             Example:cn.itcast,com.baidu      
                               B: Class or interface Capitalize each word              example: helloworld  

C: Method or variable first letter lowercase, other university-wide example: SetName ()
D: Constant capitalization, separated by _ Example: Student_max_age

3: note (the text that explains the program)

(1) Classification:

A: Single-line comment//
B: Multiline Comment/**/
C: Document Comments ()/** */
(2) The role of annotations
A: Explain the procedure, improve the reading of the code.
B: Can help us debug the program.

4: Constant (amount not changed)

Image

Binary conversions:

Decimal to other binary: In addition to the base fetch, until the quotient is 0, the remainder is reversed

The computer is in the form of twos complement when it operates data operations.

Original Code Map

Positive number of the original code and complement are the same, negative anti-code for the original code in addition to the symbol of the full negation, the complement is anti-code +1;

Original code 10110100 anti-code (except for symbol bit inversion) 11001011 complement (anti-code + 1) 11001100

Complement 11101110 Anti-code (complement-1) 11101101 original code (except for symbol bit inversion) 10010010

5. Variables

int a=3; A is a variable.

Variation Considerations:

A. Variable scope: The scope of the variable is only valid for "{}", and it has no effect out of this "{}".

B. There cannot be two variables of the same name in a curly brace

6 Data types

Figure

Figure

Long suffix with l mark, float suffix with f mark (because the integer default type is int and the decimal default type is double);

Data operations are converted by default

Figure

Figure

When you see the assignment "=" You think of the conversion type    

BYTE b1=3,b2=4,b3;b3=b1+b2;//error, B1+B2 result is int type, assignment to byte requires strong turn; b3=3+4; That's right
Force the result of type conversion data overflow calculation byte b= (byte) 130;130 binary 00000000 00000000 00000000 10000010 complement (10000010)-Anti-code (10000001)-Original code (11111110) Result is-126

Byte range graph

string addition diagram

This article is from the "Learning Summary" blog, please be sure to keep this source http://s5650326.blog.51cto.com/10667626/1694683

Java Basic Learning (i)---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.