Basic knowledge of Java programming and common examples

Source: Internet
Author: User

⒈ identifier:
Can only contain numbers, letters, underscores, $, and cannot start with a number. Semantic Intuition
Specification
Hump rule:
Such as: Method name, variable name using hump rule
Pascal Name method:
such as: Class, interface, enumeration using Pascal name method
Package Name: URL inverted, com. URL name. Name of the project. Package name, all letters are lowercase

⒉ Data type:
⑴ Basic data Types---pass by value, pass a copy, modify the copy without affecting the original data
There are 8 basic data types in ①java: int-integer, long-long, short-short, byte-bytes
②char-character, float-single-precision floating-point type, double-double-precision float, boolean-boolean

⑵ reference data Type--passed by reference, pass is pointer (address), if modification affects existing data

⑶ "Difference"
① Basic Data type: Declares the space directly in the stack memory, and holds the data directly in the current space;
The value in the variable is passed when the value is assigned.
The base data type is value-passed.
② Reference data type: Declaring a reference data type (an array or an object) will store the actual data in heap memory.
At the same time, declare an array name or object name in the stack memory, and store the first address in the heap memory;
Therefore, when you use the array name to assign a value, the address is passed.
The reference data type is a pass-through address


⑷ Data type Conversions

① Automatic Conversion
char = "int"
byte = "short =" int = "LONG =" float = "Double"
From low to high turn, waste storage space

② Coercion Type conversions
Turn from high to bottom, loss of data accuracy, out of bounds

⒊ "Process Control statement"
⑴break
End this layer loop and continue execution of the statement following the loop

⑵continue
Skip the remaining statements in this loop and proceed to the next loop
Note : When continue acts on the while loop, it is important to note that the variable UPDATE statement is placed above the continue;
Otherwise it is easy to cause a dead loop.

⑶return
Ends the current method directly, encounters a return, and all code in the method is no longer executed

⑷for cycle (used when the number of cycles is determined)

⑸while and Do-while (used when cycle times are uncertain)

⒋ "Classic Examples"

"Within 100 prime"

"The first 20 items of Fibonacci series"

"Bubble Sort"

"Binary Search"

Basic knowledge of Java programming and common examples

Related Article

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.