zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然java开发常用类库学习笔记:System类

    public class SystemDemo01{
        public static void main(String args[]){
            long startTime = System.currentTimeMillis() ;    // 取得开始计算之前的时间
            int sum = 0 ;            // 声明变量
            for(int i=0;i<30000000;i++){    // 执行累加操作
                sum += i ;
            }
            long endTime = System.currentTimeMillis() ;    // 取得计算之后的时间
            // 结束时间减去开始时间
            System.out.println("计算所花费的时间:" + (endTime-startTime) +"毫秒") ;
        }
    };
    public class SystemDemo02{
        public static void main(String args[]){
            System.getProperties().list(System.out) ;    // 列出系统的全部属性
        }
    };
    public class SystemDemo03{
        public static void main(String args[]){
            System.out.println("系统版本:" + System.getProperty("os.name")
                + System.getProperty("os.version")
                + System.getProperty("os.arch")) ;
            System.out.println("系统用户:" + System.getProperty("user.name")) ;
            System.out.println("当前用户目录:" + System.getProperty("user.home")) ;
            System.out.println("当前用户工作目录:" + System.getProperty("user.dir")) ;
        }
    };
    class Person{
        private String name ;
        private int age ;
        public Person(String name,int age){
            this.name = name ;
            this.age = age;
        }
        public String toString(){    // 覆写toString()方法
            return "姓名:" + this.name + ",年龄:" + this.age ;
        }
        public void finalize() throws Throwable{    // 对象释放空间时默认调用此方法
            System.out.println("对象被释放 --> " + this) ;
        }
    };
    public class SystemDemo04{
        public static void main(String args[]){
            Person per = new Person("张三",30) ;
            per = null ;    // 断开引用
            System.gc() ;        // 强制性释放空间
        }
    };
  • 相关阅读:
    VC连接数据库方式
    vc中有关数据类型的转换
    获得MFC窗口指针方法总结
    Windows 中绘图以及Windows 的图形设备接口(GDI )
    C#访问远程共享加锁文件夹
    C#操作注册表全攻略
    学习asp.net比较完整的流程
    sogou rank查询接口
    jquery星级插件、支持页面中多次使用
    防止网页被嵌入框架的js代码
  • 原文地址:https://www.cnblogs.com/tszr/p/12152897.html
Copyright © 2011-2022 走看看