title: Struct like objects in Java
body: <p>Is it completely against the Java way to create struct like objects?</p>
  
  <pre><code>class SomeData1 {
      public int x;
      public int y;
  }
  </code></pre>
  
  <p>I can see a class with accessors and mutators being more Java like.</p>
  
  <pre><code>class SomeData2 {
      int getX();
      void setX(int x);
  
      int getY();
      void setY(int y);
  
      private int x;
      private int y;
  }
  </code></pre>
  
  <p>The class from the first example is notationally convenient.</p>
  
  <pre><code>// a function in a class
  public int f(SomeData1 d) {
      return (3 * d.x) / d.y;
  }
  </code></pre>
  
  <p>This is not as convenient.</p>
  
  <pre><code>// a function in a class
  public int f(SomeData2 d) {
      return (3 * d.getX()) / d.getY();
  }
  </code></pre>