title: Using Hashtable, Arraylist. Getting info from them
body: <p>I have a chatprogram which contains users and channels. My next quest is to get a list of channels which one user is in. How should this be done?</p>
  
  <p>Here are the codes as of now:</p>
  
  <p><strong>ChatFrontImpl:</strong></p>
  
  <pre><code>private Hashtable&lt;String, ArrayList&lt;String&gt;&gt; channels = new Hashtable&lt;String, ArrayList&lt;String&gt;&gt;();
  private ArrayList&lt;Client&gt; clients;
  
  public synchronized boolean registerClient(Client client, String password) throws RemoteException {
  if(!u.logIn(client.findName(), password)){
      System.out.println("Wrong username or password!");
      return false;
  }
  if (!clients.contains(client)) {
      try {
          clients.add(client);
          updateJlist();
          System.out.println(client.findName() + " registered.");
      } 
      catch (Exception e){
          System.out.println("error in method registerClient(): " + e);
      }
      return true;
  }else
      return false;
  } 
  
  public void connectChannel(String username, String channel) throws RemoteException{ 
      if(isUserRegistered(username)){
          if (!channels.containsKey(channel)) {
              String message = "User " + username + " entered the channel";
              channels.put(channel, new ArrayList&lt;String&gt;());
              channels.get(channel).add(username);
              notifyChannelSystem(channel, "SYSTEM", message);
              notifySelf(username, "Write /? for avaliable commands");
          }
          else{
              if(channels.get(channel).contains(username)){ 
              } 
              else {
                  channels.get(channel).add(username);
                  String message = "User " + username + " just entered the channel";
                  notifyChannelSystem(channel, "SYSTEM", message);        
            }
          }
      }
  }
  </code></pre>