Object class Java.lang.Object(class): Is the parent of any “reference type” in Java. Includes custom classes, classes in class libraries, and arrays

Both inherit toString() and equals() methods

1. ToString: The toString method is automatically called when printing a reference type, but the toString method in the parent Object class prints the address value. You need to override the toString method in your own class to print the values of all attributes

If the equals method is not overridden, then by default the Object address comparison of the == operator is false as long as it is not the same Object.

If you want to compare the contents of objects, that is, two objects are the same if all or part of the specified member variables are the same, you can override equals. Override the toString method in the same way

1. Equals (Object o1,Object O2) Equals equals equals equals equals equals equals equals equals equals equals equals equals equals equals

Although based on the equals method overridden on Objects, the equals method of Objects is more secure and does not generate null pointer exceptions

Two constructors

Const Date (long m); const Date (long m);

Public long getTime(): gets the value of the millisecond represented by the Date object; Public void setTime(long m): setTime(long m): setTime(long m): setTime(long m); The Date represented by this Date object is changed; DateFormat: java.text.DateFormat(abstract class): a utility class that “formats” Date. Abstract classes cannot create objects; they use the subclass SimpleDateFormat class to create objects

The SimpleDateFormat(String Pattern) constructor takes the format of the date

Public static void main(String[] args) {SimpleDateFormat SDF = new SimpleDateFormat(” YYYY “) HH mm mm ss second “); String STR = sdf.format(new Date()); / / System. The format method out. Println (STR); Public static void main(String[] args) throws ParseException {String STR = “2018-09-04”; SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”); // This format must “match” the date format in the string otherwise an exception is thrown. Date date = sdf.parse(str); System.out.println(date); } Calendar class package name: java.util.Calendar(Abstract class), also an abstract class, can not create objects, subclass: GregorianCalendar (subclass) can use a simple way to obtain this subclass object:

    Calendar c = Calendar.getInstance();
Copy the code

1). Public int get(int field): obtain the value of a field;

Common methods:

Public static void arrayCopy (Object SRC,int srcPos,Object dest,int destPos,int length)

// The array you want to copy, the starting position, the array you want to copy, the length of the copyCopy the code

This method copies the specified contents of one array into another (two arrays).

Public static long currentTimeMillis(): currentTimeMillis();

Date = new Date();

          long m = date.getTime();
Copy the code

3. End the VM

Public static void exit(int status): Terminates the JVM. That’s the end of the program. The value of status is 0

StringBuilder class package name: java.lang.StringBuilder(class), does string concatenation

  1. Constructor: StringBuilder() The no-parameter constructor automatically applies an array of 16 empty Spaces for the object, expands to a 32-bit array when the added string can’t fit, and destroys the array of 16 if there are no more strings to add in this way

  2. Public StringBuilder AppEnd public StringBuilder appEnd public StringBuilder appEnd public StringBuilder AppEnd

Returns a value of type StringBuilder, which can be called again directly

1. Byte short char int long float double Boolean

Corresponding reference type:

Byte Short Character Integer Long Float Double Boolean

2. Convert a type to a string:

int a = 24;

String s = Integer.toString(a);

To convert a string to a type:

String a = “24”;

int age = Integer.parseInt(a);

To convert, you need to convert to int, so there can be no other type of value in the string

All wrapper classes can be converted, but Character cannot

3. Packing and unpacking: Packing: Assign “basic type” to “Packing type “;

Unpacking: Assign “package type” to “base type “:

In Java, wrapper types are treated the same as primitive types. For example, an int value can be assigned directly to an Integer wrapper type:

Integer a = 10; / / packing

int b = a; // if (a ++ = a++)