📄 题目和另一种解法.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 + -