System类其实也是个蛮有趣的类呢,下面小菜鸟给点小代码,喜欢的亲们可以自己敲敲看,有点意思
小菜鸟找到了一篇不错的介绍System类的文章,本文的小代码懂了之后,有兴趣的亲们可以去看看http://blog.csdn.net/woshishuoshuoa/article/details/10107345哦
代码:
public class MySystem {
public static void main(String[] args){
long startTime = System.currentTimeMillis();//取得系统当前时间
int sum = 0;
for (int i = 0; i < 30000; i++) {
sum+=i;
}
long endTime = System.currentTimeMillis();//取得进行过累加后的系统时间
System.out.println("所经过的时间是:"+(endTime - startTime));
System.getProperties().list(System.out);//列出系统的全部属性
System.out.println("系统版本"+System.getProperty("os.name")
+System.getProperty("os.version")+System.getProperty("os.arch"));
//获取当前系统版本
System.out.println("当前用户"+System.getProperty("user.name")+"当前用户目录"
+System.getProperty("user.home")+"当前用户工作目录"+System.getProperty("user.dir"));
}
}