Common API
Object class
toString method
Any class which has a default toString method, after creating the object if the object is output directly to the output of the address, because the output is a direct call to toString method toString method is the default output address
in order to output the contents of the object must be inside to override toString method in which the class, Alt + Insert then select toString, and then select all the variables (usually the default), then ok, then the output can be directly inside the class variables
Rewrite
direct output
equals method
ToString same way, if the two objects are more direct comparison of their address value, no meaning, so in order to compare their value, it must be rewritten, Alt + Insert, select equals () and hashCode () and has next to it
and then you can compare the equals method by calling the object of the two objects are the same
Date class
date () constructor parameter empty, the current system time acquisition
date () constructor parameter band, the incoming millisecond value to a date
to date to milliseconds value getTime ()
The method of the DateFormat format class date format, i.e. according to their required output conversion
1.创建SimpleDateFormat对象,构造方法中传入指定的模式
2.调用SimpleDateFormat对象中的format方法,因为返回值是一个字符串所以需要一个字符串类型的变量来接收
The formatted date reconverted to the default format
1.创建SimpleDateFormat对象,构造方法中传入指定的模式
2.调用SimpleDateFormat对象中的parse方法,因为返回值是Date类型的值所以需要一个Date类型的变量来接收
注意:因为可能传入的参数类型不符合所以就会出现红色下划线的警示,这时候需要Alt+回车选择第一个,即当出现异常时,声明此异常
This is converted under normal circumstances
it is converted under unusual circumstances
System class
currentTimeMillis () method: Returns the current time from milliseconds at 0:00 on January 1, 1970 of
Arraycopy () method: an array of a specified number of copies to the number of another array which
StringBuilder class
与string类不同的是,stringbuilder类是字符串缓冲器,可以添加任意类型的字符串并返回给本身以提高效率
append方法:向对象里面添加字符串
tostring方法:将stringbuilder对象转换为String对象
基本类型与字符串类型之间的相互转换
基本类型→字符串类型
1.直接加双引号
2.包装类的tostring方法
3.String类的valueof方法
字符串类型→基本类型
通过包装类的静态方法parseXXX()