package cn.sasa.demo2;

public class SystemDemo {
public static void main(String[] args) {
func_arraycopy();
} static void func_1() {
//currentTimeMillis() 获取当前的毫秒数 返回值long
long time1 = System.currentTimeMillis();
//System.out.println(time1);
for(int i = 0; i<100000; i++) {
System.out.println(i);//循环体里有内容才会执行循环
}
long time2 = System.currentTimeMillis();
//System.out.println(time2);
System.out.println(time2 - time1);
} static void func_2() {
//exit() ---------终止程序
while(true) {
System.out.println("hi");
System.exit(0);//终止程序
}
//System.out.println("hello"); //因为前面有exit(),程序不会运行这一步,编译报错
} static void func_gc() {
//gc 垃圾回收
//当没有引用再指向该对象时,JVM会自动回收堆中的对象,同时调用该回收对象的finalize()方法
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
new Person("sa",12);
System.gc();
} static void func_3() {
//System 类 getProperties 获取系统参数
System.out.println(System.getProperties());
System.out.println(System.getProperty("java.class.version"));
} static void func_arraycopy() {
//System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
//src ----源数组
//srcPos ----源数组的起始索引
//dest ----目标数组
//destPos ----目标数组的起始索引
//length ----复制几个
Person[] src = new Person[10];
for(int i = 0; i<10; i++) {
src[i] = new Person("sa",i);
} Person[] dest = new Person[20];
for(int i = 0; i<10; i++) {
dest[i] = new Person("user",i);
} System.arraycopy(src, 5, dest, 2, 3);
for(int i = 0; i<dest.length; i++) {
String pstr = dest[i].toString();
System.out.println(pstr);
}
}
}
package cn.sasa.demo2;

public class Person {
private String name;
private int age; public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
} public void setAge(int age) {
this.age = age;
}
public int getAge() {
return this.age;
} public Person(String name, int age) {
this.name = name;
this.age = age;
} public void finalize() {
System.out.println("测试gc ------ 垃圾回收了");
} public String toString() {
return "name:"+this.name +" age:"+this.age;
}
}

java System类的一些静态方法的更多相关文章

  1. java System类、Math类、Arrays类

    一 System类 1.概念 在API中System类介绍的比较简单,我们给出定义,System中代表程序所在系统,提供了对应 的一些系统属性信息,和系统操作. System类不能手动创建对象,因为构 ...

  2. Java System类看到的一点小记

    System类 位置java.lang包中 是final类,不能被继承,不能被修改 ,不能被实例化 private System(){}私有的构造函数,不允许被其他对象进行实例化 public fin ...

  3. Java System类

    java 不支持 全局方法 和 变量, system 类 中所有成员都是静态的, 而要引用这些变量和方法,可直接system作为前缀,

  4. Java—System类入门学习

    第三阶段 JAVA常见对象的学习 System类 System类包含一些有用的字段和方法,他不能被实例化 //用于垃圾回收 public static void gc() //终止正在运行的java虚 ...

  5. Java(System类,currentTimeMillis())

    CurrentTimeMillis()方法来记录程序的执行时间.currentTimeMillis()方法将返回自1970年1月1日午夜起到现在的时间,时间单位是ms,如果要记录程序中一段程序的运行时 ...

  6. 关于JAVA System常见类的一些总结

    一.JAVA System类概述 1.概述: System 类是一个抽象类,所有的字段和方法都是静态的,即不能被实例化.其中包含一些有用的类字段和方法,它不能被实例化.在 System 类提供的设施中 ...

  7. java学习笔记之System类

    System类常用总结 System类概述 java.lang.System类,系统属性信息工具类 常用静态方法: 1. public static long currentTimeMillis() ...

  8. Java学习笔记25(System类)

    System类,系统类,包含的是静态方法,无法创建对象 这里介绍几个简单的方法,其他一些在后边用到的时候会讲 类方法: currentTimeMillis():获取当前毫秒数 package demo ...

  9. Java 基础 常用API (System类,Math类,Arrays, BigInteger,)

    基本类型包装类 基本类型包装类概述 在实际程序使用中,程序界面上用户输入的数据都是以字符串类型进行存储的.而程序开发中,我们需要把字符串数据,根据需求转换成指定的基本数据类型,如年龄需要转换成int类 ...

随机推荐

  1. Spring Security 认证流程

    请求之间共享SecurityContext原因:

  2. 文件加密 解密 pdftk openssl gpg vim

    openssl加密和解密 . openssl des -salt -in file -out file.des openssl des -d -salt -in file.des -out file ...

  3. 使用UWA GOT优化Unity性能和内存

    优化百科: https://blog.uwa4d.com/archives/Index.html https://blog.uwa4d.com/archives/Introduction_UWAGOT ...

  4. [Tensorflow] Cookbook - Object Classification based on CIFAR-10

    Convolutional Neural Networks (CNNs) are responsible for the major breakthroughs in image recognitio ...

  5. SpringBoot自定义错误信息,SpringBoot适配Ajax请求

    SpringBoot自定义错误信息,SpringBoot自定义异常处理类, SpringBoot异常结果处理适配页面及Ajax请求, SpringBoot适配Ajax请求 ============== ...

  6. SpringBoot(十六)-- 使用外部容器运行springBoot项目

    spring-boot项目需要部署在外部容器中的时候,spring-boot导出的war包无法再外部容器(tomcat)中运行或运行报错. 为了解决这个问题,需要移除springBoot自带的tomc ...

  7. VS Release模式调试

    c++ -> 常规 -〉调试信息格式 选 程序数据库(/Zi)或(/ZI) c++ -> 优化 -〉优化 选 禁止(/Od) 连接器 -〉调试 -〉生成调试信息 选 是 (/DEBUG)

  8. play mp3 in c#

    using System; using System.Runtime.InteropServices; using System.Text; using System.IO; using System ...

  9. 使用Curator操作ZooKeeper

    Curator是Netflix公司开源的一个ZooKeeper client library,用于简化ZooKeeper客户端编程.它包含如下模块: Framework:Framework是ZooKe ...

  10. DOM常用事件绑定方式与实例

    一.常用的事件 onclick 点击事件 模态框实例 <input type="button" id="b1" style="width:50p ...