One, polymorphic
1. Polymorphism exists in inheritance and interfaces.
2. The indeterminate behavior is placed in the parent class.
3. Subclasses must override the indeterminate behavior in the parent class.
Second, abstract class
1. Keyword abstract.
Example: Public abstract class shap{
public abstract void View ();
}
2. An indeterminate behavior method is placed in an abstract class.
3. You cannot build an instance because of an abstract method.
4. There are constructors, methods, and properties in the abstract class.
The subclass invokes the parameterless constructor of the parent class by default.
If the parent class is a parameter constructor, the subclass also has a constructor to invoke, the keyword super.
Third, the interface
1. Put the polymorphic method.
2. Create--Interface.
3. The subclass's keyword implements class name.
Four, Packaging class
1. The wrapper class is the object type.
2.Integer
(1) A null value can be received, but when the calculation is involved, do not assign a null value and the null pointer exception is reported.
(2) Integer b = new integer (100);
Integer b = 100; There is automatic boxing function.
System.out.println (b++); Automatic unpacking function
Example: Integer a = 200;
Integer B = 200;
System.out.println (A = = B); False
= = Same Object comparison
System.out.println (A.equals (b))//True
Comparison of values for equals objects
(3) method
Intvalue (), Doublevalue (), Bytevalue (), Floatvalue (), Longvalue (), Shortvalue (), toString (), parseint ()//String to integer number
Example: int V1 = B.intvalue ();
3.Byte
(1) Byte a = 100;
(2) The method is similar to an integer.
Byte B = a.parsebyte ("100"); If the standard numeric string is converted to bytes.
4.Boolean
(1) Boolean a = true;
(2) method
A.booleanvalue ();
A.tostring ();
A.parseboolean ();
Example: String s = "true";
Boolean a = Boolean.parseboolean (s);
System.out.println (a); True
False when S is a different value
5.Character
(1) Character C = ' a ';
(2) method
Charvalue ()
Isletter ()//Whether it is a letter
IsDigit ()//is a numeric character
Iswhitespace ()//is a space
Isuppercase ()//whether capital letters
toUpperCase ()//Specify uppercase form
V. String of strings
1.String message = new String ("Hello World");
String Hello = "Hello world";
2. String Pool
Example: (1) String message = "Hello World";
String Hello = "Hello world";
SYSTEM.OUT.PRINTLN (message = = Hello); True
When the string pool already has Hello World, two objects will use the same Hello World in the string.
(2) String message = new string ("Hello World");//If you add. Intern (), the string pool will be used, otherwise the new will not take advantage of the string pool
String Hello = "Hello world";
SYSTEM.OUT.PRINTLN (message = = Hello); False
3. Immutability of strings
String a = "Hello";
String b = "Hello";
B = B + "World";
System.out.println (a); Hello
In this case, the string pool has hello, world, Hello World
4. Reduce garbage in the string pool
StringBuffer bf = new StringBuffer ();
Bf.append ("Hello");
Bf.append ("World");
Bf.tostring ();
Just the string pool only Hello World
Method of 5.String
(1) Length (); String length
(2) equals (); Comparison of object values
(3) indexOf (); The string is first searched for the position of the string, the subscript starts at 0, and no return-1 is found
(4) lastIndexOf (); Finds the first occurrence of a string from the end, and the subscript value is also the starting number
(5) Replace (change, replace); T replaces the specified string
(6) split (); Returns an array of split strings
Example: String stu1 = "Li Ming -20-Male";
String stu[] = Stu1.split ("-");
System.out.println (stu[1]); 20
(7) Substring (start, end); Intercepts the specified length string, has no end value, and intercepts the end
(8) toUpperCase (); lowercase to uppercase
(9) toLowerCase (); Uppercase to lowercase
(+) charAt (); Takes the nth character in a string
(one) concat (); Link string
(a) contains (); Whether the string exists in the found string
(+) EndsWith (); The end of the judgment contains the string, you can determine the file type
Example: A.endswith (". mp4");
(+) StartsWith (); Determine if the string is included in the beginning of the URL protocol
Example: Url.startswith ("/http");
(Equalsignore) (); Ignoring case, judging value comparison
(+) getbyte (); Get bytes
Java Foundation Chapter 11th (polymorphic, abstract class, interface, wrapper class, String)