Summary of basic Java learning content

Source: Internet
Author: User

Java basic content;

1) keywords in Java:
Common keywords for the future:
Class,public,static (Object-oriented section), the key word in the Process Control statement: If,else.
Basic data type: Int,byte,short ...
Synchronized (in multi-threaded)
2) Identifier: A sequence of characters that give a class, interface, variable, or method a name
3) Package Name: Single-level package (single directory)/multi-level package (multi-level directory) (often used)
4) class/interface: Single word: Capitalize the first letter of the word
A) Multiple words: Capitalize the first letter of each word:
Method: Single word: all lowercase letters
Multiple words: First word lowercase, starting with the second word each word capitalized (printxing ())
b) Constants: Single word: All uppercase letters
Multiple words: All uppercase letters, separated by underscores between words and words
5) Variables:
1> three elements: 1) data type 2) variable name 3) initialization value;
A) Classification of data types:
Basic data type: 4 in Class 8
1. Integer type
a>; BYTE range -128~127
b>; Short
c>; INT--The wrapper class type for the base data type-?int (reference type): Integer
d>; Long
2. Floating-point type float double
3. Character type: Char---? basic type-? Reference type: Character
4. Boolean Type: Boolean
attention to content;
1) Default type promotion: Byte,short,char do not convert, once participate in the operation? int type
2) Forced type conversion: According to the specific needs to use, it is recommended to try not to force the type conversion, it loses the accuracy of the data!
Target data type variable name = (target data type) (variable value);
3) Mastering: When + becomes string concatenation: string + any data = new string
"Hello" +1+ ' 0 ' = hello1 (string concatenation)
"Hello1" + ' 0 ' =hello10
' 0 ' +1+ "Hello" = 49hello
Three values in the ASCII code table: When the character participates in the operation, it will find his corresponding value in the table.
' 0 ' ~48
' A ' ~97
' A ' ~65

Two; operators
The operators are divided into:
1. Arithmetic operator: extended operator: ++/--
2. Assignment operator: +=,/=,*= (extended assignment operator), hiding forced type conversions
3. Comparison operator: = = cannot be written as =
4. Logical operators: logical double and &&, logical double or | |
5. Logic double and &&: With short-circuit effect, if the condition expression on the left is false, then the right side does not execute
6. Logical Double or | | : Has a short-circuit effect, if the condition expression on the left is true, then the right side does not execute
7. Ternary operators:
(conditional expression)? True result: false result;
III. Process Control Statements
Process Control statements are divided into;
1. Sequential structure;
The code starts from the top down;
2. Select the structure;
1> If statement:
Format 1:if (expression) {...}
Format 2: Actual development, use the most, for two conditions to judge
if (expression) {
...
}else
2> Switch statement

3. Cyclic structure
The cyclic structure is divided into;
1>.for Cycle
for (initialization statement; Conditional statement; Step statement) {
loop body statement;
}
2>.while cycle;
A> while (conditional expression) {
Loop statement Body
}

 b>       扩展格式:(优于基本格式)                                  初始化语句 ;                                while(条件表达式){                                    循环体语句;                                    步长语句;                                }

3>.do while loop
The third type of a> LOOP statement structure:
Do-whle:
Basic format
do{
loop body statement;
}whiel;

                            c>扩展格式:                                    初始化语句;                                    do{                                        循环体语句;                                        控制体语句;                                    }while ;

4> double-layer for loop

For loop nesting:
For (initial value, conditional statement, step statement)
{
For (initial value, conditional statement, step statement)
{
loop body content statement;
}
}
Four, jump control statements
1) Break: means interruption, end meaning, concluding sentence;
Break: cannot be used alone, typically in a switch statement, or in a loop statement
2) Continue: Continue meaning, jump out of the current loop and go straight into a loop
Continue: cannot be used alone, use multiple in a loop statement
3) Retrun: The return value of the method will bring back a result
public static return value method name (parameter type 1 variable 1, parameter type 2 variable name) {
Return
}
public static: The method is static, and it is a common method (write today, Static)
return value (data type): What type to return, and what type of data to end with, depending on the specific requirements
Method Name: Give the current code block name, naming rules: Single word: letter all lowercase multiple words: first word all lowercase, second word start each word first letter capital
Return: Returns the calculated result of the current code to the caller
A> Method Invocation:
1) Separate calls
a> separate call, no meaning, no output results
B> when the demand, the shape is directly output in the console, no specific return value, but also conform to the method specification,---> Keywords: void substitution syntax return value
C> does not have a specific method for returning values, and is suitable for individual invocation
2) Output Call
Direct output of the results, write dead, can not operate on the results
3) Assignment invocation: A method with a return value type, which is recommended to use an assignment call, which can result in further action

B> Precautions:
1) methods and methods are lateral relationships, and a method can no longer define a method
2) When defining a method, the formal parameter must have a data type, otherwise there is a problem
3) in main main (), when invoking a method, the actual parameter does not need a data type
4) Where there are curly braces, there can be no semicolon, there is no curly brace where there is a semicolon

Interview questions?
What is the difference between break and continue?
break; Used to force the execution of the interrupt loop and end the loop.
Continue; Used to interrupt the cycle and advance to the next cycle.

Summary of basic Java learning content

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.