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) Mastery: When "+ Becomes string concatenation": string + any data = new string
"Hello" +1+ ' 0 ' = hello1 (string concatenation)
"Hello1" + ' 0 ' =hello10
' 0 ' +1+ "Hello" = 49hello (at this time 0 because there is a single quotation mark, the ASCLL code table of 48, ' 0 ' +1 this plus becomes the operator, 48+1==49, and then + "Hello", at this time + is "string concatenation character")
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-Z can be launched yourself)
' A ' ~65 (A-Z can be launched yourself)
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: "= =" (different from "=" meaning, "= =" before equals = = equals sign, "=" is the assignment after the equal sign to the equal sign)
4. Logical operators: logical double and &&, logical double or | |
{logical double and &&: With short-circuit effect, if the condition expression on the left is false, then the right side does not execute
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> Extended format: (better than basic format)
initialization statements;
while (conditional expression) {
loop body statement;
Step statement;
}
3>.do while loop
The third type of a> LOOP statement structure:
Do-whle:
Basic format
do{
loop body statement;
}while (conditional statement, step statement);
C> Extended Format:
initialization statements;
do{
loop body statement;
Control Body Statement;
}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: Interrupt can continue execution of the following loop (jump out of the current loop, directly into a loop)
Continue: Use multiple in a looping statement (cannot be used alone)
3) Retrun: Return value of method, bring back a result
public static return value method name (parameter type 1 variable 1, parameter type 2 variable name) {
Return
}
Permission modifier: public + static (static adornment) method is static and is a common method
Return type: What data type is the result of the final calculation and (what data type is the result of that type of acceptance)
Method Name: Is the code block for this function name: Naming rules: A word letter all lowercase; multiple words: the first word is lowercase, the second word starts with an uppercase letter;
Return: A line in a method indicating that a result is brought back
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?
1.break jumps out of the total loop, no longer executes the loop (ends the current loop body);
2.continue jumps out of the loop and proceeds to the next loop (ending the loop that is being executed and entering the next loop condition);

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.