- 生成0到100之间的伪随机数
- 主动运行垃圾回收器,相当于呼喊保洁阿姨
- 非0就是异常终止jvm
- 对程序进行记时
- System自带的复制数组的方法
1. 生成0到100之间的伪随机数
2. 运行垃圾回收器,相当于呼喊保洁阿姨
3. 非0就是异常终止jvm
4. 对程序进行记时
5. System自带的复制数组的方法
package cn.njupt;
import java.util.Random;
public class ArrayReverse {
public static void main(String[] args) {
randomOne2Hundread();
garbageWithSystemgc();
systemExit0();
currentTimeMillisTest();
arrayCopyTest();
}
public static void arrayCopyTest() {
int[] src = {11,22,33,44,55,66};
int[] dest = new int[src.length];
for (int i = 0; i < dest.length; i++) {
System.out.println(dest[i]);
}
System.out.println("----------------------");
System.arraycopy(src, 0, dest, 0, src.length);
for (int i = 0; i < dest.length; i++) {
System.out.println(dest[i]);
}
}
public static void currentTimeMillisTest() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
System.out.println("*");
}
long end = System.currentTimeMillis();
System.out.println(end - start);
}
public static void systemExit0() {
System.exit(0);
System.out.println(11111111);
}
public static void garbageWithSystemgc() {
for (int i = 0; i < 100; i++) {
new Garbg();
System.gc();
}
}
public static void randomOne2Hundread() {
Random rs = new Random();
int a = rs.nextInt(100) + 1;
System.out.println(a);
}
}
class Garbg {
@Override
public void finalize() throws Throwable {
System.out.println("clean!");
}
}