MATH-1041

Added "toString" method. Thanks to Sean Owen.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1532679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2013-10-16 08:08:07 +00:00
parent e65901dcb8
commit da0bbbb9a6
2 changed files with 11 additions and 0 deletions

View File

@ -133,4 +133,9 @@ public class Pair<K, V> {
return result;
}
@Override
public String toString() {
return "[" + getKey() + ", " + getValue() + "]";
}
}

View File

@ -73,6 +73,12 @@ public class PairTest {
Assert.assertFalse(p1.hashCode() == p2.hashCode());
}
@Test
public void testToString() {
Assert.assertEquals("[null, null]", new Pair<Object, Object>(null, null).toString());
Assert.assertEquals("[foo, 3]", new Pair<String, Integer>("foo", 3).toString());
}
/**
* A mutable integer.
*/