title: Java Tuple/Pair
body: <p>My Pair class:</p>
  
  <pre><code>public class Pair&lt;o,t&gt; {
  
        private o one;
        private t two;
  
        public Pair(o one, t two) {
          this.one = one;
          this.two = two;
        }
  
        public o getO() { 
            return one;
        }
  
        public void setO(o one) {
            this.one = one;
        }
  
        public t getT() {
            return two;
        }
  
        public void setT(t two) {
            this.two= two;
        }
  }
  </code></pre>
  
  <p>In my main application I fill a list with the pair object:</p>
  
  <pre><code>List&lt;Pair&lt;Integer, String&gt;&gt; test = new ArrayList&lt;Pair&lt;Integer, String&gt;&gt;();
  Pair&lt;Integer, String&gt; pair;
  
  pair.setO(1);
  pair.setT("A");
  test.add(pair);
  
  pair.setO(2);
  pair.setT("B");
  test.add(pair);
  </code></pre>
  
  <p>I want to be able to get the integer value only by list index, eg. for-loop to write out A, B, etc. How would I do that? Is there a simpler way of doing such a thing in Java?</p>