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

📄 题目和另一种解法.txt

📁 thinking in java 第三版 第五章 11题 答案
💻 TXT
字号:
.  Following the form of the example Lunch.java, create a class called ConnectionManager that manages a fixed array of Connection objects. The client programmer must not be able to explicitly create Connection objects, but can only get them via a static method in ConnectionManager. When the ConnectionManager runs out of objects, it returns a null reference. Test the classes in main(?). 

class Connection{
    private Connection(){}
    public static Connection Make(){
        return new Connection();
    }
}
public class ConnectionManager{
    public static Connection[] func() {
     Connection[] n1={Connection.Make(),Connection.Make(),Connection.Make()};
     return n1;
    }
    public static void main(String[] args){
     System.out.print("the length of the array is:");
     System.out.println(func().length);
     System.out.println("a fixed array of Connection objects is created");
}
}

⌨️ 快捷键说明

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