java.lang.Object类的说明:
equals() 、 toString() 、 getClass() 、 hashCode() 、 clone() 、
finalize() 、 wait() 、 notify() 、 notifyAll()
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
objectExer that = (objectExer) o;
if (age != that.age) return false;
return name != null ? name.equals(that.name) : that.name == null;
}
Objects
2.Math类(所有成员都是静态的)
java.lang.Math提供了一系列静态方法用于科学计算。其方法的参数和返回值类型一般为double型。
int abs(int a) 返回参数的绝对值
double ceil(double a) 向上取整
double floor(double a) 向下取整
int round(float a) 四舍五入
int max(int a,int b)
int min(int a,int b)
double random() 返回值为double的正值[0.0,1.0)
double pow(double a,double b) 返回a的b次幂的值
System类
System类代表系统,系统级的很多属性和控制方法都放置在该类的内部。该类位于java.lang包。
由于该类的构造器是private的,所以无法创建该类的对象,也就是无法实例化该类。其内部的成员变量和成员方法都是static的,所以也可以很方便的进行调用。
方法:
native long currentTimeMillis() 返回1970~当前时间经历的毫秒值(以毫秒为单位)时间戳
void exit(int status) 终止当前的java虚拟机,非0状态码表示异常终止
arraycopy(数据源数组,起始索引,目的地数组,起始索引,拷贝个数) 拷贝数组
void gc() 调用垃圾回收器
String getProperty(String key)
src 源数组
srcPos 源数组中的起始位置
dest 目标数组
destPos 目标数据中的起始位置
length 要复制的数组元素的数量
【典型代码】
数组拷贝
方式一: System.arraycopy()
System.arraycopy(arr1,0,arr2, arr2.length - 3,3);
for (int i = 0; i < arr2.length; i++) {
int i1 = arr2[i];
System.out.print(i1 + " ");
}
方式二: Arrays.copyOf(源数组,新数组长度)