Today Plant Science:
/ * 2019.08.19 started to learn, to make this shift. * /
1.Date tools:
= DATE DATE new new DATE (); // this time the SimpleDateFormat SDF = new new the SimpleDateFormat ( "the MM-dd-YYYY" ); sdf.format (DATE) ----> Time to String sdf.parse (Source) - -> string transfer time
2.Object class: is the parent of all classes.
All information open classes: ctrl + o
public String toString () // Returns a string representation of the object return the this .getName (); // rewritable
public boolean equals (Object obj) { String name = ((People)obj).getName() ; return this.name == name ; //重写
3.instanceof Keywords: to determine whether an object belongs to a class.
Format: The object instanceof class ----> Boolean return type
IF (Animal the instanceof Dog) { ((Dog) Animal) .func1 (); } IF (Animal the instanceof Cat) { ((Cat) Animal) .func2 (); } // was used for determination downcast
4. anonymous inner classes: new interface or an abstract class.
t.test ( new A () { public void a() { } } ) ;
The packaging added:
String a = "1" ; String b = "2" ; int m = Integer.parseInt(a) ; int n = Integer.parseInt(b) ; System.out.println(m+n) ; ----> 3
6. singleton design pattern
In Java applications, singletons can guarantee a JVM, only one instance of the object exists.
Mode: ① starving single embodiment implemented: pre-instantiated
Private Singleton1 () // constructor private Private static Final Singleton1 Single1 = new new Singleton1 () // static factory mode: public static Singleton1 the getInstance () { return Single1; }
② lazy single case realization: When the first call is instantiated (plus synchronized synchronization to avoid creating multiple simultaneous access objects)
private static Singleton2 single ; //工厂: public static Singleton2 getInstance() { if (single == null) { single = new Singleton2() ; } return single ; }