I Shortcut key
A common shortcut
-
Alt + Enter: reference class or prompt
-
Ctrl +O: view the methods in our inherited class or interface and the methods we want to implement
-
Ctrl + Alt + b: view the methods in the interface implementation class (that is, when we use interface programming, when we call the implementation class method, we can only enter the method defined in the interface, but use this shortcut key to directly enter the method of the implementation class
-
Alt + insert : set/get; Construction method; toString; Rewrite method...
-
Ctrl + Alt + t: package the code in a block, such as try / catch; Synchronized et al
-
Ctrl+Alt+O to optimize imported classes and packages
-
Ctrl+N to quickly open the class
-
Ctrl+F, find
II. Infrequent shortcut keys
Ctrl+E, recent files
Ctrl+Shift+E, recently changed files
Ctrl+F12 to display the structure of the current file
Ctrl+P to display parameter information
Alt+Shift+C, recent changes
[debugging part, compilation] Ctrl+F2, stop Alt+Shift+F9, select Debug Alt+Shift+F10, select Run Ctrl+Shift+F9, compile Ctrl+Shift+F10, run Ctrl+Shift+F8, view breakpoint F8, step F7, step Shift+F7, smart step Shift+F8, step Alt+Shift+F8, force step Alt+Shift+F7, force step Alt+F9, run to cursor Ctrl+Alt+F9, Forcibly run to F9 at the cursor, restore the program Alt+F10, locate the breakpoint Ctrl+F8, switch the line breakpoint Ctrl+F9, and generate the project
[refactoring] Ctrl+Alt+Shift+T, the refactoring menu will pop up, Shift+F6, rename F6, move F5, copy Alt+Delete, safely delete Ctrl+Alt+N, inline
[find]
Ctrl+R, replace F3, find next Shift+F3, find previous Ctrl+Shift+F, find Ctrl+Shift+R in path, replace Ctrl+Shift+S in path, search structure Ctrl+Shift+M, replace structure Alt+F7, find usage Ctrl+Alt+F7, display usage Ctrl+F7, find usage Ctrl+Shift+F7 in file, and highlight usage in file
Three Java foundation half
3.1 foundation HelloWorld
-
Only one public is allowed for a file
-
Class initial capital
-
Constant capitalization
3.2 basic data type
1.boolean
2.char
3. Integer:
1.byte 2.short 3.int 4.long
4. Decimal
1.float 2.double
3.3 type conversion
1. Large to small, forced, loss of accuracy
2. From small to large
3.4 variables
1. Local variable: defined in the method. After the method is executed, the variable will be destroyed
2. Member variable: defined in the class, outside the method, the instance object has the same life
3. Class variable: static
3.5 access modifier
1.public: all
2.private: in the same class
3.default: in the same package
4.protected: different packages with inheritance relationship
3.6 control modifiers
1.static: the static member variable of the class needs to be called in the static method
2.final: @1,psfi. @2,psfs
3.7 abstract classes
1. There can be non abstract methods in abstract classes
2. If a class has an abstract method, the class must be an abstract class
3. Extract the public attributes and methods to the parent class, but in some methods, because the implementation of different subclasses is different, we can abstract this method
3.8 operators
1. + + / -: + + operates before assignment, + + assigns before assignment
2. Condition operator: data type variable = (condition)? True: false
3. ||: ||||||||||||||||||||||||||
4. Judge whether it is the same class: instanceof, forced conversion
5. Priority: ()
3.9 circulation structure
1.for: for can be used when the number of times is determined
2.while: when conditions are determined, use while
3.do...while: execute once before judging
3.10 conditional statements
1.if...else
2.swith: break;--> The bowl didn't wash and went on strike. Continue: just don't brush the broken bowl, and continue to brush the rest
3.Math--String: understand
3.11 differences between string / StringBuffer / StringBuilder
1.StringBuffer: it is not modified by the final keyword and can be modified multiple times Multithreading using stringbuffer is safe and not fast compared with stringbuilder
2.StringBuilder: there is no final keyword modification, which can be modified multiple times Single thread using stringbuilder is fast, but not safe enough
3. String: the final keyword is used in the string class, so the string object is immutable and cannot be modified
3.12 array
1. One dimensional array / multidimensional array
2.Arrays tool: arrays Sort() method: natural ascending order. Arrays.toString() print
3.13 date
1.new Data():
//Define a time Date date = new Date(); //Formatted time class definition SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println(simpleDateFormat.format(date));
2. String and time are interchanged (SimpleDataFormat):
//A string time object is passed from the front end String dateStr = "2021-09-21"; //Define a time formatted class SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); Date dateStr1 = simpleDateFormat1.parse(dateStr);//Parse data System.out.println(dateStr1);
3. Time stamp:
System.out.println("Start preparing..."); long StartTime = System.currentTimeMillis(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } long endTime = System.currentTimeMillis()-StartTime; System.out.println("The test time is: "+endTime/1000.0f);
4.Calender:
Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); System.out.println(year); int month = c.get(Calendar.MONTH) + 1; System.out.println(month); int week = c.get(Calendar.DAY_OF_WEEK) - 1; System.out.println(week);
3.14 regularization
1. Function: check whether the format is correct; Replacement; cutting
String str = "2"; String regex = "[0-9]"; boolean matches = Pattern.matches(regex,str); System.out.println(matches);
//Replace all //1. Original data String str = "548w45wewe465ef4e57e6e6"; //2. Rules for replacing letters String regex1 = "[a-zA-Z]+";//At least one //3. Replacement System.out.println(str.replaceAll(regex1, "*")); String regex2 = "\\d+"; System.out.println(str.replaceAll(regex2, "~"));
//Cut String str = "oneTtwoTthreeDfourDfive"; String regex = "[A-Z]"; String[] split = str.split(regex); for (String sp : split) { System.out.println(sp);
3.15 get keyboard input, command line
1.new Scanner(System.in);
2.next: cannot get a string with spaces.
3.nextLine: end with Enter, that is, the nextLine() method returns all characters before entering carriage return. Spaces are allowed in the string
3.16 object oriented
1. Encapsulation: control whether our data and code can be accessed externally at will
2. Inheritance: reduce duplicate code
3. Polymorphism: a method has different results Conditions: (1) inherit (2) override (3) the reference of the parent class points to the object of the child class
Main function: decoupling
3.16 rewrite / reload
1. Override: the subclass replicates the method of the parent class, which is enhanced override
2. Overloading: parameters with different names for the same method; Adapt to different situations and construct