博客
关于我
(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/

你可能感兴趣的文章
OpenWrt固件编译刷机完全总结
查看>>
Open××× for Linux搭建之二
查看>>
Open×××有线网络时使用正常,无线网络时使用报错的解决方案
查看>>
Opera Mobile Classic Emulator
查看>>
Operation not supported on read-only collection 的解决方法 - [Windows Phone开发技巧系列1]
查看>>
OperationResult
查看>>
Operations Manager 2007 R2系列之仪表板(多)视图
查看>>
operator new and delete
查看>>
operator new 与 operator delete
查看>>
operator() error
查看>>
OPPO K3在哪里打开USB调试模式的完美方法
查看>>
oppo后端16连问
查看>>
OPPO软件商店APP侵权投诉流程
查看>>
Optional类:避免NullPointerException
查看>>
Optional讲解
查看>>
ORA-00923: 未找到要求的 FROM 关键字
查看>>
ORA-00932: inconsistent datatypes: expected - got NCLOB【ORA-00932: 数据类型不一致: 应为 -, 但却获得 NCLOB 】【解决办法】
查看>>
ORA-00942 表或视图不存在
查看>>
ORA-01034: ORACLE not available
查看>>
ORA-01152: 文件 1 没有从过旧的备份中还原
查看>>