取时间差:
public class SystemDemo01 {
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
long endTime = System.currentTimeMillis();
System.out.println("Time costed: " + (endTime - startTime));
}
}
取系统参数:
public class SystemDemo02 {
public static void main(String[] args) {
System.getProperties().list(System.out);
}
}