Quick Index
Code Explanation


Hello, my name is Pair

I simply hold a set of two values.

My values are generic type params (T and S) meaning you can use any types you like.

Read more about me below.

I have two ivars:
public class Pair<T, S> {
	private T first;
	private S second;

	//etc (more code follows)

}
This constructor assigns the passed
values to my two ivars. The param types
match the ivar types (typical).
	public Pair(T aFirst, S aSecond)  {
		this.first = aFirst;
		this.second = aSecond;
	}
Standard getter method that returns the ivar "first" (of corresponding type T)
	public T getFirst()  {
		return this.first;
	}
Standard getter method that returns the ivar "second" (of corresponding type S)
	public S getSecond()  {
		return this.second;
	}
Standard setter method that sets the ivar "first" (with param of corresponding type T)
	public void setFirst(T newFirst)  {
		this.first = newFirst;
	}
Standard setter method that sets the ivar "second" (with param of corresponding type U)
	public void setSecond(S newSecond)  {
		this.second = newSecond;
	}

Complete Source Code


Here is all my code.

Have Fun.

Your friend,
Pair

package pair.model;


public class Pair<T, S> {

	private T first;
	private S second;

	//--------------------------
	//Constructors Here

	public Pair(T aFirst, S aSecond) {
		this.first = aFirst;
		this.second = aSecond;
	}

	//--------------------------
	//Accessors

	public T getFirst() {
		return this.first;
	}
	
	public S getSecond() {
		return this.second;
	}
	
	public void setFirst(T newFirst) {
		this.first = newFirst;
	}
	
	public void setSecond(S newSecond) {
		this.second = newSecond;
	}

	//--------------------------
	//Services
	
	@Override
	public String toString() {
		return getFirst().toString() + " -- " + getSecond().toString();
	}

}