博客
关于我
(Java基础类库 )System类
阅读量:333 次
发布时间:2019-03-04

本文共 690 字,大约阅读时间需要 2 分钟。

(Java基础类库 )System类

System类在Java编程中扮演着重要角色,提供了丰富的系统级方法

  • 数组拷贝:public static void arrayCopy(Objec src,int srcPos,Object dest,int destPos,int length);
  • 获取当前的日期时间数值:public static long currentTimeMillis();
  • 进行垃圾回收:public static void gc();

范例:操作耗时的统计

package Java基础类库;public class Runtime类 {	public static void main(String[] args) {		long start = System.currentTimeMillis();//获取开始的时间		 System.out.println("----------用for循环产生大量垃圾----------");		 String str ="";		 for(int x= 0;x<30000;x++) {			 str+=x;		 }		 long end = System.currentTimeMillis();//获取结束的时间		 System.out.println("耗时为:"+(end-start));	}}

----------用for循环产生大量垃圾----------

耗时为:1232

在System类中,gc()方法仅作为对Runtime类的gc()方法调用

该方法主要用于清除不再被引用的一部分内存

转载地址:http://pgwe.baihongyu.com/

你可能感兴趣的文章
Oracle 11g忘记sys、system、scott密码该这样修改!
查看>>
Oracle 11g数据库安装和卸载教程
查看>>
Oracle 11g数据库成功安装创建详细步骤
查看>>
Oracle 11g超详细安装步骤
查看>>
Oracle 12c中的MGMTDB
查看>>
Oracle 12c安装报错Installation failed to access the temporary location(无法访问临时位置)...
查看>>
Oracle 9i数据库管理教程
查看>>
ORACLE Active dataguard 一个latch: row cache objects BUG
查看>>
oracle avg、count、max、min、sum、having、any、all、nvl的用法
查看>>
Oracle BEQ方式连接配置
查看>>
oracle Blob保存方式,oracle 存储过程操作blob
查看>>
Oracle BMW Racing sailing vessel帆船图
查看>>
ORACLE Bug 4431215 引发的血案—原因分析篇
查看>>
Oracle Business Intelligence Downloads
查看>>
Oracle cmd乱码
查看>>
Oracle Corp甲骨文公司推出Oracle NoSQL数据库2.0版
查看>>
【Docker知识】将环境变量传递到容器
查看>>
uniapp超全user-agent判断 包括微信开发工具 hbuilder mac windows 安卓ios端及本地识别
查看>>
Oracle DBA课程系列笔记(20)
查看>>
oracle dblink 创建使用 垮库转移数据
查看>>