含有正则的笔记(Contains regular notes)
Practice:
Java design pattern singleton (Singleton)
A class requires only one object a teacher, a network management
Requirements: the number of students to be fixed, the teacher shared all classrooms, all network management Classroom sharing, and will not change
(encapsulation, inheritance, arrays, static, final, abstract)
Rewriting is the overload that occurs between father and son classes, and is overridden, overridden, or overridden in this class
Run with packets: compile the source file, run the outermost package?
Javac, test, java, -d. Or, javac, -d. Test, java, -d, javac, Testi, java,
Java com. tarena. test. Testi
April 2nd
Clone:
There are two ways to implement cloning: to implement the interface Cloneable: to override the clone method permission; protected to public
Shallow clones are cited, and deep cloning is the object of memory
Equals object is used to achieve the "=二”
==always better than the memory address equals method can be changed (rewritten)
Public, Boolean, equals (Object, obj) {
If (obj = = null) {
Return false: ) else if (obj, instanceof, Student) {
Student st = (Student) obj:
Return st. id = = this, id;
Return / st. name, equals (name); adjusting the ratio of String
}// type determines the equals plus ID, HashCode should also be decided
Return false: / / or compiled to
}// overrides the equals method requires special skilled
Public, int, hashCode () {
In accordance with the HashCode agreement / need to override the. Equals HashCode rewrite rewrite
Int type=41: / / just a prime number represents a type
Return type*97+id; / / reduce weight rate is not absolute
//return, type*97+name. hashCode ();
The Java language interval is before closing and then opening
The String class method * charAt (); endsWith (), startsWith () determines whether a string starts or ends with a string; equal signor ecase (string anotherstring)区分火不区分大小写; getbytes ()把 string 拆成 byte [] : indexof (string str)在
含有正则的笔记Containsregularnotes 来自淘豆网www.taodocs.com转载请标明出处.