String manipulation
(1) String str = new string (); equivalent to String str = "(void)"; (point to an empty string), not String str; (objects that do not point to any strings)
(2) string initialization can contain alternative parts such as%s,%d,%x, and then use the String.Format () method to select alternative values for these parts, or use the System.out.format () method Output
(3) Trim () method is useful to remove space before and after a string
(4) The StringBuffer class generates a mutable string object, and thestring class generates an immutable object, and if you frequently want to manipulate a string, use the former
Static variables and static methods
(1) Staticmethod can only call other static methods, only static data can be accessed , cannot be referenced in any way this or Super
Generic type
(1) when using a generic class, the passed-in type parameter cannot be a native type and must be a reference type
Collection Class
(1)ArrayList is a collection class implemented with an array, the access element is fast, the insertion and deletion of elements is slow;LinkedList is a collection class implemented with an array, Insert Delete element block, access element is slow, both can use the Add () method and the Remove () method to insert and delete elements
(2)Mapmappings can define mapping objects, which are key-value pairs (<Key,value>), using theput ()method adds a key-value pair, using theget ()method to obtain the value according to the key, usingRemove ()method deletes the corresponding key-value pairs according to the key;KeySet ()method,values ()Methods andEntrySet ()methods to get the keys, values, and keys separately&value
(3)theaddall method can put elements from one collection into another collection
Encapsulation and inheritance
(1) writing programs should learn to use encapsulation, the member variables of the class apply the static keyword decoration to make it invisible (access), and then you can define The public method to let external access to information
(2) the use of inheritance: to put the structure and behavior of the common in the parent class, subclasses can inherit the code in the parent class, and expand according to their own needs
(3) a subclass in Java can inherit only one parent class, which inherits all non-private methods except the constructed method in the parent class , and all non- private variables If the subclass has the same non- private method as in the parent class, and the parameter list and return value type are the same, the methods in the parent class are overwritten, but the same name method in the parent class can still be called with the Super keyword
(4) The final modified method can inherit the quilt class, but cannot be overwritten; The final decorated class cannot be inherited
Java Learning Notes (ii)