ApiSystem

 System表示 java运行的平台
 * 
 * 不能直接创建System类的对象
 * 
 * System.in :系统标准的输入流
 * System.out: 系统标准的输出流
 * System.err: 系统标准的错误输出流
 * @author jerry
 *
 */
public class SystemDemo {


public static void main(String[] args) {


//系统标准的输入流
Scanner sc = new Scanner(System.in);

//访问环境变量

Map<String, String> getenv = System.getenv();

System.out.println(getenv);

System.out.println("==========");
Properties properties = System.getProperties();

System.out.println(properties);

// key=value ;键值对
//user.dir 这个属性:表示 当前项目的默认查找路径。 相对路径的开始
String userDir = System.getProperty("user.dir");
System.out.println(userDir);


try {
InputStream is = new FileInputStream("a.txt");
byte[] b = new byte[1024];
is.read(b);

System.out.println(new String(b));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}




// 获取一个对象的hashCode

Student stu = new Student("jerry","male",20,"轻工业");


System.out.println(stu.hashCode());

System.out.println(System.identityHashCode(stu));


// gc():提供一个方式,来运行垃圾回收器,但是真正是否回收内存,不一定,jvm会根据
//实际情况来判断,也就是运行gc()不一定有效

System.gc();

//exit()程序退出


// System.exit(1);// 当前程序强行退出;后续的程序不再执行

System.out.println("hello world");



//currentTimeMillis():返回当前时间的 long类型的表示形式
// 是距离 "计算机的元年" 的时间差 1970 1,1,00:00:00
System.out.println(System.currentTimeMillis());


//应用场景
//method1()执行了多少时间
long start = System.currentTimeMillis();
method1();

long end = System.currentTimeMillis();

System.out.println((end-start)+"毫秒");


//arraycopy() : 数组操作,数组的copy

//数组大小的扩容问题,。


     int[] array  = new int[]{1,2,3};
     
     int[] newArray = new int[array.length*2+1];
     
     
     System.arraycopy(array, 0, newArray, 0, array.length);
     
     System.out.println(Arrays.toString(newArray));
}

public static void method1(){
for(int i=0;i<100000;i++){
System.out.println("hello world");
}
}



     




}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值