Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Paar<T> {
- private T wert1, wert2;
- // Methoden
- public Paar(T w1, T w2)
- {
- this.wert1 = w1;
- this.wert2 = w2;
- }
- public T getWert1()
- {
- return this.wert1;
- }
- public T getWert2()
- {
- return this.wert2;
- }
- public String toString()
- {
- return "(" + String.valueOf(this.wert1) + ", " + String.valueOf(this.wert2) + ")";
- }
- public boolean equals(Object o) {
- if(o instanceof Paar<?>) {
- Paar<?> p = (Paar<?>) o;
- // nun koennen Sie auf die Attribute des uebergebenen Objektes
- // ueber p zugreifen
- if(wert1.equals(p.wert1) && wert2.equals(p.wert2))
- {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement