title: Java passing data between two classes
body: <p>I have a very stupid and elementary questions, however I can't seem to get around it. I am trying to pass data between 3 classes, so this is the approach I took:</p>
  
  <p>Class A</p>
  
  <pre><code>public class GroupChat {
  
      public String message;
      public String myId;
      public String otherID;
  
      public GroupChat() {
  
      }
  
      public String getOtherID() {
          return otherID;
      }
  
      public void setOtherID(String otherID) {
          this.otherID = otherID;
      }
  
      public String getMyId() {
          return myId;
      }
  
      public void setMyId(String myId) {
          this.myId = myId;
      }
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  }
  </code></pre>
  
  <p>Class B - which generates the data on button click</p>
  
  <pre><code>GroupChat chat = new GroupChat();
  chat.setParticipants(participants);
  chat.setMyId(userId);
  chat.setOtherID(id);
  chat.setMessage(message);
  </code></pre>
  
  <p>When I print out the log of these variables in the GroupChat class, all is perfect.</p>
  
  <p>However, when I attempt to use the getters to get data to class C, which is where I need them, they are returning a null value.</p>
  
  <p>Class C</p>
  
  <pre><code>GroupChat chat = new GroupChat();
  chat.getMessage(),
  chat.getItemView(),
  chat.getMyId(),
  chat.getOtherID());
  </code></pre>
  
  <p>I even tried to log the data in the GroupChat class. When I enter the data, using the setters, everything is fine, however when logging the data on the getters, these are returning null. There must be something in the GroupChat class which is nullifying the variables.</p>
  
  <p>Can someone please point me to the right direction?
  Thanks a million.</p>