The basic syntax of the Java basic

I. Notes
1. What is a comment?
Text explanation for the program
2.Java comments in classified format
single-line comments: // comment text format
multi-line comments: format / * comment text * /
documentation comment: Format / ** * Annotation /

Second, keyword
1. What is the key?
Was given a special meaning in the Java language word
2. Keyword Considerations
goto and const as a reserved word exist, does not currently use Notepad ++ or similar eclipse such advanced development tools for keywords have a special color-coded, very intuitive.

Keywords are those?
Write pictures described here

Write pictures described here

Third, the identifier
1. What is the identifier?
Programs need to name our own
2. part of
the English uppercase and lowercase letters, numbers and characters _ $
3. Notes
can not begin with a number
can not be the Java keywords
are case sensitive
Camel writing

Note: See the name to know justice can be.

* Fourth, the variable *
1. What is a variable?
Variables used to store program data used in execution
of data stored variables can be changed

2. Variable Definition Format
data type variable name = initial value;

In essence, the variable is actually a small area of ​​memory, using the variable name to access this area, therefore, must first apply for each variable before use (statement), then you must assign (filled with content), in order to use.

Fifth, data types
Java language is strongly typed language, for each data has a clearly defined data types, memory allocation in a different memory space for each data type.
Write pictures described here
Write pictures described here

Note the use of variables:
define the rules of data types and variables, the definition of variables Precautions:
1. The first variable is initialized, you can use
a scope issue 2. definition of variables with a scoped variable name must be unique.
3. The range of data types - the problem of cross-border
4. Data type conversion issues
conversion assignment (default conversion cast +)
conversion operation, control the + operator (default conversion)

The default conversion (the little assignment to large)
byte-Short-Long-float-int-Double

Cast (assigned to the large small)
target type = variable name (target type) (converted data);

Special points:
a float type assignment
a float F1 =. 1;
a float F2 = 1.0;

Sixth, the operator
1. Arithmetic operators
arithmetic operators (+, -, *, /,%, +, -, a distinction difference between front and rear)
2. assignment operator
assignment operator (=, + =, - =, * =, / =,% =)
3. relational operators (comparison operators)
relational operators (comparison operators)
==: equal ==
=: not equal (non)!!
>: greater than
<: less than
> =: greater than or equal
<=: less than or equal
results are the relational operator a boolean, true or to false
4. logical operation
& (and), | (or), (non) && (short-circuited),! || (or short circuit), ^ (XOR)
rule:
& a is false, and false logic and
| is true, true or logical
! Non false to true, the non true false
&& a false, and short-circuiting and false
|| a true True or shorted
^ two different, was true, false to the same

5, ternary operator

Format
(relational expression) Expression 1: Expression 2;?

If the relational expression evaluates to true, the result of operation is the expression 1;
if relational expression result is false, the result of the operation is the expression 2;

Seven expression Concept
Concept expression: operand + operator, on the formation of an expression

Eight, escape character
focus is to master the shift character "\" role
Symbol role
\ n newline
\ t horizontal tab
\ 'single quote
\ "double quote
\ generate a slash

Published 31 original articles · won praise 4 · Views 3527

Guess you like

Origin blog.csdn.net/qq_29074261/article/details/78751903