First chapter initial Java
1. History of development
1995 jdk1.0 jdk5.0 (1.5) Jdk6 Jdk7 jdk8
Jdk7 start: String type can also be used as switch (byte/short/int/char/enum enum type) {
}
2. Three aspects of technology:
Javase Foundation
Java EE
Javame
3. Three types of note lines//
Multi-Line/* * *
Document/** */More for document introduction
4. Three steps of the program execution:
Writing source program Xxx.java
Compiled Javac xxx.java---"xxx.class bytecode file, cannot be opened directly
Run the contents of Java Xxx---> Output programs
Compiling: The process from. Java to. class
Decompile: The process from. class to. Java,
The anti-compilation software will let us see the system is added by default, the method of non-parametric construction
5. Naming rules for identifiers:
1) can only be numbers, letters, underscores, dollar signs
2) numbers cannot begin
3) class name: Initial capitalization, exactly the same as the file name, followed by the first letter of the word Pascal name
Method name, variable name: First letter lowercase, subsequent words first capitalization hump name method
Package name: All lowercase, dot delimited, domain name inverted, cannot start with dot
6. class file Structure
Outer layer:
public class class Name {
Inner layer: Inlet method
public static void Main (string[] args) {
}
}
Supplement: Construction method
public class name () {//No parameter construction method
}
public class name (String Name,int age) {//With parameter construction method
This.name=name;
This.age=age;
}
7. Output statements
System.out.print (); No line wrapping after output, must have parameters
System.out.println (); Output line wrap, can not have parameters, equivalent to print a blank line
"" The contents of the double quotation marks are output as-is, some content cannot be output and need to be escaped
\ "\" Console Output ""
\ \ Escape out a \
\ t: a series of spaces
\ n: Subsequent content line-wrapping output
8. Specifications for Programming:
The position of the curly braces after the class file and method
Write only one statement per line
The code has to be indented
Curly braces, parentheses, and brackets appear in pairs.
9. Configure Environment variables
Way 1:path The bin path of the JDK
Mode 2: Introduce the Java_home variable to the previous level of the bin directory
Path%java_home%\bin; Win7 add; win10 not add;
10. Virtual Machines
The JVM corresponds to a different operating system, and the compiled virtual machine is automatically interpreted as the corresponding machine-identified binary code
The source code is written once and runs everywhere.
First chapter initial Java
1. History of Development 1995 jdk1.0 jdk5.0 (1.5) Jdk6 Jdk7 jdk8
Jdk7 start: String type can also be used as switch (byte/short/int/char/enum enum type) {
}
2. Three aspects of technology: Javase Javaeejavame
3. Three note lines//Multiple lines/* * * Document/** */
4. Three steps of the program execution:
Write source program Xxx.java compile Javac xxx.java---xxx.class bytecode file, do not open the contents of running Java XXX---> output program directly
Compile: Process decompile from. Java to. class: From. class to. Java,
The anti-compilation software will let us see the system is added by default, the method of non-parametric construction
5. Identifier naming rules: 1) can only be a number, letter, underscore, dollar sign 2) number can not begin 3) class name: uppercase, with the file name exactly, followed by the first letter of the word Pascal method name, variable name: first letter lowercase, followed by the first letter of the word hump name method Package name: All lowercase, dot delimited, domain name inverted, cannot start with dot
6. class file structure//Outer layer: public class class Name {//inner: Ingress method public static void main (string[] args) {
}
}
Add: Construction method public class name () {//No parameter construction method
}
public class name (String Name,int age) {//With parameter construction method
This.name=name;this.age=age;}
7. Output statements
System.out.print (); After the output is not automatically wrapped, must have the parameter System.out.println (); Output line wrap, can not have parameters, equivalent to print a blank line
"" The contents of the double quotation marks are output as-is, some content cannot be output, you need to escape \ "\" console output "\ \ escaped a \\t: a series of spaces \ n: Subsequent content wrap output
8. Specification of the writing procedure: The position of curly braces after class files and methods
Write only one statement per line code to have indentation curly braces, parentheses, brackets in pairs appear.
9. Configure Environment variables
Mode 1:path JDK Bin path Mode 2: Introduce java_home variable refers to the upper level of bin directory path%java_home%\bin; Win7 add; win10 not add;
10. The virtual machine JVM corresponds to different operating systems, and the compiled virtual machine is automatically interpreted as the corresponding machine-identified binary code
The source code is written once and runs everywhere.
Chapter II variable data types and operators
Data type:
Reference type: string string type Array interface class
String name= "ABC";
Basic data type: four classes of 8
numeric type int x=1; integer 4 kinds: Long 64bit integer type int 32 bit integer type short 16 bit bit byte 8 bit integer (8 bit is a Byte of bytes)
Decimal 2 kinds: Double 64bit dual precision floating point number float 32bit single precision floating point number
Character Type 1 char 16bit 2 bytes
Boolean Type 1 Boolean 8bit 1 bytes
Char zifu= ' a '; 97
int Zimu=zifu;
int num=97; Char number= (char) num;
BYTE x=127; 1111111int y=x; 000000001111111 byte--->int auto-convert, auto-boost
int m=50; byte n= (byte) m; Cast int---->byte cast 16bit 000000000000000000 8 bit 0 binary number corresponding binary number 0000000000 1000000001 2000000010 every two in one
3000000011 4000000100
1271111111 12810000000
Data type conversions
Cast display conversion (target type) auto-transform (auto-boost, implicit conversion)
Java Primary knowledge