Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带数组的Java类_Java_Arrays - Fatal编程技术网

带数组的Java类

带数组的Java类,java,arrays,Java,Arrays,我有一个Java类,用于一家公司,它在全国各地有不同的分支机构,每个分支机构都会跟踪其客户列表。我如何实现这一点,使“伦敦”分行只提取使用过该分行的客户列表,而无法查看其他分行的客户列表?我正在考虑一个包含数组的客户机类,但我正在努力找到一种将这些类链接在一起的方法 public class Branch implements Manager { //instance variables that will be available to children of Branch private

我有一个Java类,用于一家公司,它在全国各地有不同的分支机构,每个分支机构都会跟踪其客户列表。我如何实现这一点,使“伦敦”分行只提取使用过该分行的客户列表,而无法查看其他分行的客户列表?我正在考虑一个包含数组的客户机类,但我正在努力找到一种将这些类链接在一起的方法

public class Branch implements Manager {

//instance variables that will be available to children of Branch
private String branchName;



// constructor
public Branch(String name) {
    this.branchName = name;
}


//Returns the location of the branch as a String
@Override
public String getBranch() {
    return this.branchName;
}

//Returns a String representation of customers who have used the Branch
@Override
public String getAllCustomers() {
    return "Customer list will go here";
}
那么:

Map<String, List<Clients>>
Map
?


因此,您可以将分支映射到客户列表。

如果
伦敦船级社扩展分支
格拉斯哥船级社扩展分支
,则
伦敦
将无法获取
格拉斯哥
的私有字段
伦敦
格拉斯哥
甚至无法访问
分行


使用
protected
或package protected access修饰符。

您确实意识到,如果将数组作为类的私有成员放置,则只能直接访问特定对象?当然,但将创建分支类的实例,这意味着“伦敦”将能够看到“格拉斯哥”的客户端列表?