I. Installation of JDK and directory structure
When the JDK installation package is installed, it will be installed on the C drive by default, and the directory is C:/Program Files/java,java folder, which is divided into JRE and JDK folder.
Jdk-bin Compilers and tools
Jdk-demo Demo
Jdk-docs class library document in HTML format
Jdk-include files used to compile local methods
JDK-JRE Java Runtime Environment file
Jdk-lib Class library file
Jdk-src class Library source files
Add system variable java_home and path path, participate in Network tutorial
Second, the running example
command-line window, type the following command:
Javac Welcome.java//compile Welcome.java into Welcome.class and send to Java Virtual machine (compile)
Java Welcome//virtual machine execution Class byte code, only need to provide the class name, do not take the extension. class or. java (run)
Recommend using Eclipse to write Java programs, Eclipse provides an integrated development environment
Third, the design structure
Access modifier: The level of access to this code by other parts of the control program
Public
Key words:
Class
Class name writing method: The first letter must be uppercase, save the file name must be the same as the public class name, a Java program can have only one public class, the class must have the main method of public, the format is fixed, the execution of the program first executes the main method
Data base type:
Integral type
Byte:1 bytes
Short:2 bytes
Int:4 bytes
Long:8 bytes
Hex 0x begins with octal 0
Floating point Type
Float:4 bytes
Double:8 bytes
Positive/negative Infinity large/nan
Floating-point values are not suitable for use in financial calculations where rounding errors are prohibited, the stored decimals are not accurate, and to contain no rounding errors, the BigDecimal class should be used
Char type
2 bytes
Single character
\U0000-\UFFFF hexadecimal values in place of character constants using Uniclode encoding
In addition to the escape character \u, there are escape sequences that represent special characters, such as \ n \ r \ \ \ "And so on.
Boolean type
True/false
Variable declaration: Data type + variable name, and variable must be initialized
Constants: final+ data type + constant name, can no longer be changed after being assigned, constant name uses all uppercase, common static final sets a class constant, class constants may be used in multiple methods in a class
Arithmetic operators: subtraction, self-increment self-subtraction
Relational operators: = =! = < > <= >= && | | ! ?:
Mathematical Functions and constants:
Math Class-Math.sqrt (x); Math.pow (X,a); Math.PI, if you do not want to add the prefix "math" before the mathematical method name and the constant name, simply append the import static java.lang.math.* to the top of the source file;
The result of the floating-point type obtained by the Strictmath class is fully predictable.
Type conversions: Small number of bytes can be converted to a large number of bytes, large number of bytes converted to a small number of bytes need to cast, such as int y= (int) x;
String:
1) Sub-string
String greeting= "Hello";
String s=greeting.substring (0,3); S= "Hel"
2) splicing
Two strings with Plus + stitching
3) string cannot be modified
4) Detect if strings are equal
S.equals (t); Returns true if equal
"Hello". Equalsignorecase ("Hello"); Excludes case. Do not use = = to determine whether two strings are equal, and this operator only determines whether two strings are placed in the same position.
5) empty string and null string
Str.length () ==0 or Str.equals ("") check whether it is empty
Str==null Check if NULL
Java-basic (1)