user2904400 user2904400 - 1 year ago 72
Java Question

Java Class with Array

I have a Java class that is used for a companies different branches located around the Country, and each branch will keep a track of its client list. How can i implement this so that "London" branch only pulls the list of clients that has used that branch, but not able to see the client list of other branches? I am thinking of a client class that contains an array, but im struggling to find a way of linking the classes together

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
public String getBranch() {
return this.branchName;

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

Answer Source

How about:

Map<String, List<Clients>>


So you can map a branch to a list of clients.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download