美文网首页
Runtime对象

Runtime对象

作者: menmo_O | 来源:发表于2017-12-28 11:39 被阅读0次

    Runtime对象
    该类并没有提供构造函数
    说明不可以new对象,那么会直接想到该类中的方法都是静态的。
    发现该类中还有非静态方法。
    说明该类肯定会提供方法获取本类对象。而且该方法是静态的,并返回值类型是本类类型。

    由这个特点可以看出该类使用了单例设计模式完成。
    

    该方法是static Runtime getRuntime();

    class RuntimeDemo 
    {
        public static void main(String[] args) throws Exception
        {
            Runtime r = Runtime.getRuntime();
            Process p = r.exec("notepad.exe SystemDemo.java");
    
            //Thread.sleep(4000);
            //p.destroy();
        }
    }
    

    相关文章

      网友评论

          本文标题:Runtime对象

          本文链接:https://www.haomeiwen.com/subject/jgmmgxtx.html