Java Basics for Beginners to learn Java notes

Source: Internet
Author: User

The first time to learn Java, some basic common shortcuts and some very basic knowledge points (the notes are scattered more chaotic)

Java is an object-oriented and cross-platform language, namely: Write once, run anywhere;

Java not only applies to stand-alone applications and web-based programs, but also to create attachment programs for consumer devices, such as mobile phones, handheld devices, and more.

Java Naming conventions
The initials can be letters, underscores ' _ ', ' $ ' symbols
followed by any number of numbers, letters, underscores, ' $ ' symbols
Usually the first letter is lowercase and the first letter of the word is capitalized. Example: Myscore

MyEclipse Programming Java Code Shortcuts (Novice does not recommend the use of MyEclipse and other development integration tools, preferably using EditPlus or Notepad to write code)

Ctrl+l Chack

Ctrl+o Search Method
Ctrl+shift+r Check Class

Alt+shift+s F Format Specification collation
Ctrl+shift+f

CTRL + A Select all
ctrl+/notes
ctrl+shift+/ctrl+shift+\ Comment Paragraph

alt+/Quick Completion

Ctrl+shift+o Quick Guide Package

Basic data type:
Numeric type: Int (+) short (+) long (+) double (+) float (+) byte
Non-numeric: char (+) Boolean

int to String intger.valueof
int to double automatic type promotion
double to int (int) + variable coercion type conversion

The difference between break and continue
Application: Break can be used in switch structure and loop structure; Continue can only be used in loop structure
function (in loop structure): Break statement terminates a loop, the program jumps to the next statement outside the loop block;
Once you encounter the Continue keyword, the code after continue is no longer executed and goes directly to the next loop

Array

Error: Array subscript out of bounds Java.lang.arrayindexoutofboundsexception:4

for (int i = 0; i < c.length; i + = 2)//take array subscript as an even number, cycle efficiency problem

Tri-Wood operation
(Logical judgment)? (The result is true): (the result is false)

Scattered knowledge points
Random random = new random ();


= = compares the memory address
Equals is the value of the comparison variable "male". Equals ()

Switch cannot pass in a double type (a talent of more than 1.7 versions)

If else is more suitable for interval selection, switch is more suitable for single target value

Precision Drift Bigdecimal.valueof

DecimalFormat format=new decimalformant ("#.00") retain two decimal places

Compiler Error Run error logic error code specification Fault tolerant mechanism readable simplicity redundancy


/+ * + Enter comment on method called method comment or dynamic comment Check method body ALT + SHIFT + J

/* * for text comment

Ctrl+shift+i viewing the value of a variable

F6 debugging the next line, F8 debugging the next breakpoint, F5 into the current method, F7 jump out of the current method to return to the previous layer

A foreach loop, I is the value of the subscript at each loop, I equals a[1] or a[n]
When you can determine the number of cycles, use a For loop,

Write Java program ideas: Think good ideas, define variables, write logic down, encapsulate

Java Basics for Beginners to learn Java notes

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.