Inheritance extends final key polymorphism is based on the interface interface Exception exception package access can control permissions private default protect public
Abnormal
An exception is the equivalent of a person's illness.
Error exception error generally not saved errors, virtual machine crashes, etc., can not be saved exception save the exception two ways to save: Try Catch statement block catch exception try code catch that may be an exception problem code to solve the exception problem Finally the code that will execute anyway
The throws keyword, which is used to declare the throw exception thrown when the exception object is generated. Because the keyword itself will produce an exception, you need to throw or declare ...
After declaring an exception, there are two workarounds, one is to catch the exception, the other is to declare the catch exception again, to suggest a direct capture in the main function, and not to throw it to the JVM. The exception object has three common methods, such as E.getmessage () to print the base name of the exception E.printstacktrace () Print to the default output stream E.printstacktrace (PrintStream s) to the specified location
A 7.0 literal long character represents a catch block parallel write generic that can receive string strings in a shorthand switch statement in a try
8.0 lambda expression, replacing inner Class) ()->{} interface can have method body 1.static keyword decoration method 2.default permission modifier modified method polymorphism: The reference of the parent class receives an object of a subclass
JDK upgrade for a total of three reasons 1, write convenient literal _ 2, Function extension enum String interface 3, improve efficiency stringbuffer (low, thread-safe) StringBuilder (high, thread insecure), Vecter (thread-safe)/arraylis T (thread insecure)
Multithreaded sychronized code FAST thread-safe unused thread insecure
Multithreading: There are multiple processes in an operating system concurrently executing a process with multiple threads in the art of war execution
Two ways to implement multithreading 1, inherit the thread class, rewrite the Run Method 2, implement the Runnable interface, implement the inside of the Run method Java is a single-inheritance thread scheduling: time-sharing scheduling preemptive scheduling (default)
Single (real) example design pattern
classDemo {//Lazy Single-case//Private Demo () {// }////private final static Demo d = null;////static Demo getinstance () {////if (d = = null)//return new Demo ();//return D;// }//A single example of a bad Han style//Private Demo () {}////Private Final static Demo d = new demo ();// //tatic Demo getinstance () {////return D;// }}
StringBuffer variable-length containers can be added to the inside of a string
PackageCOM.LLHC; Public classDemo { Public Static voidMain (string[] args) {//string s = new String ("Baixuelong");//String sss = new String ("Dhbhdjhd");//String ss = "DJDBJDBJ";// //System.out.println (S.charat (0));//System.out.println (S.endswith ("SD"));//System.out.println (s.equals ("DHBHDJHD"));//Compare Content//System.out.println (s==sss);//Compare Addresses//System.out.println (S.contains ("HB"));//Compare Addresses//System.out.println (S.touppercase ());//Compare Addresses//System.out.println (s.replace ("DH", "BXL"));//Compare Addresses//System.out.println (s.substring (3,6));//not including tail before package//stringbuffer sb = new StringBuffer ();//Sb.append (9);//Sb.append (8);//Sb.append (7);//Sb.append (6);//System.out.println (Sb.reverse ());System.out.println (Math.Abs (-3)); //receive double returns doubleSystem.out.println (Math.ceil (3.4));//receives the double type, taking the maximum integer close to this number 4 System.out.println (Math.floor (3.4));//receives the double type, taking the smallest integer close to this number 3 }}
Util (Collection/class set framework)
Single-column collection (Collection) list ArrayList (linear structure), Vector () enumration, LinkedList (bidirectional loop list) set HashTable (hash table), HashSet (hash table) TreeSet (Binary tree)
Double column collection (MAP) <key:value> one ID for one person key cannot be duplicated, value can be repeated 140202 Snow Dragon 140303 Snow Dragon HashMap TreeMap
The notation for enumerations
while (En.hasmoreelements ()) { = (String) en.nextelement (); SYSTEM.OUT.PRINTLN (name+ = = = +properties.getproperty (name)); }
hasMoreElements (), en.nextelement
Runtime and System class GC (), exit () exec () must be preset in the system environment. That receives the string type.
Generic type
Wrapper class Auto-unpacking: wrapper class split into basic data type auto-boxing: Raw data type wrapped into object char Character int Integer
Double Doble float Float
An array can hold "objects" and "Basic data types", but he is limited in length from the outset and can only hold one data type--the collection can only hold the characteristics of the object generic 1. Increased security 2. Convert run-time exceptions to compile-time 3. Eliminate forced type conversions enhanced for loop for (variable type Variable name: The name of the container that needs to be cycled) the class that implements the collection interface can be used, and the underlying array structure can also be used
Javase Basic Primer Review Note four