⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testclone1.java

📁 Java面向对象编程(随书配套源代码) 阐述了面向对象编程的思想
💻 JAVA
字号:
package chapter8;

class TestClone1 implements Cloneable
{
    int a;
    double b;
    TestClone1 cloneTest()
    {
        try
        {
            return (TestClone1) super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            System.out.println("Cloning not allowed.");
            return this;
        }
    }

    public static void main(String args[])
    {
        TestClone x1 = new TestClone1();
        TestClone1 x2;
        x1.a = 10;
        x1.b = 20.98;
        x2 = x1.cloneTest();
        System.out.println("x1: " + x1.a + " " + x1.b);
        System.out.println("x2: " + x2.a + " " + x2.b);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -