diff --git a/src/java/org/apache/commons/lang/math/Fraction.java b/src/java/org/apache/commons/lang/math/Fraction.java index a3e7a90ff..4834e41dd 100644 --- a/src/java/org/apache/commons/lang/math/Fraction.java +++ b/src/java/org/apache/commons/lang/math/Fraction.java @@ -33,7 +33,7 @@ import java.math.BigInteger; * @since 2.0 * @version $Id$ */ -public final class Fraction extends Number implements Comparable { +public final class Fraction extends Number implements Comparable { /** * Required for serialization support. Lang version 2.0. @@ -867,13 +867,12 @@ public final class Fraction extends Number implements Comparable { * with equals, because, for example, equals treats 1/2 and 2/4 as * different, whereas compareTo treats them as equal. * - * @param object the object to compare to + * @param other the object to compare to * @return -1 if this is less, 0 if equal, +1 if greater * @throws ClassCastException if the object is not a Fraction * @throws NullPointerException if the object is null */ - public int compareTo(Object object) { - Fraction other = (Fraction) object; + public int compareTo(Fraction other) { if (this==other) { return 0; } diff --git a/src/java/org/apache/commons/lang/math/NumberRange.java b/src/java/org/apache/commons/lang/math/NumberRange.java index 5f1236ffb..f74a00cd5 100644 --- a/src/java/org/apache/commons/lang/math/NumberRange.java +++ b/src/java/org/apache/commons/lang/math/NumberRange.java @@ -119,7 +119,7 @@ public final class NumberRange extends Range implements Serializable { } } - int compare = ((Comparable) num1).compareTo(num2); + int compare = ((Comparable) num1).compareTo(num2); if (compare == 0) { this.min = num1; this.max = num1; @@ -176,8 +176,8 @@ public final class NumberRange extends Range implements Serializable { if (number.getClass() != min.getClass()) { throw new IllegalArgumentException("The number must be of the same type as the range numbers"); } - int compareMin = ((Comparable) min).compareTo(number); - int compareMax = ((Comparable) max).compareTo(number); + int compareMin = ((Comparable) min).compareTo(number); + int compareMax = ((Comparable) max).compareTo(number); return compareMin <= 0 && compareMax >= 0; } diff --git a/src/java/org/apache/commons/lang/text/StrTokenizer.java b/src/java/org/apache/commons/lang/text/StrTokenizer.java index 02cbef4c9..81be54b85 100644 --- a/src/java/org/apache/commons/lang/text/StrTokenizer.java +++ b/src/java/org/apache/commons/lang/text/StrTokenizer.java @@ -458,8 +458,8 @@ public class StrTokenizer implements ListIterator, Cloneable { public List getTokenList() { checkTokenized(); List list = new ArrayList(tokens.length); - for (int i = 0; i < tokens.length; i++) { - list.add(tokens[i]); + for (String element : tokens) { + list.add(element); } return list; } diff --git a/src/test/org/apache/commons/lang/math/FractionTest.java b/src/test/org/apache/commons/lang/math/FractionTest.java index d3118c26b..f3d4f0a53 100644 --- a/src/test/org/apache/commons/lang/math/FractionTest.java +++ b/src/test/org/apache/commons/lang/math/FractionTest.java @@ -1264,11 +1264,6 @@ public class FractionTest extends TestCase { fail("expecting NullPointerException"); } catch (NullPointerException ex) {} - try { - f1.compareTo(new Object()); - fail("expecting ClassCastException"); - } catch (ClassCastException ex) {} - f2 = Fraction.getFraction(2, 5); assertTrue(f1.compareTo(f2) > 0); assertTrue(f2.compareTo(f2) == 0);