Tim Moores wrote:The compiler isn't as smart as you :-) If the return statements are hidden in the midst of "if" statements, it's not clear during a static compilation that one will ever be executed.
Tim Moores wrote:(The indexOf method looks fishy, by the way. It'll never go beyond index 0, because it returns no matter what.)
Tim Moores wrote:In the second method it's even less clear that a return will be executed before execution reaches the end of the method. What happens if "continue" is executed at the end of the loop?
Campbell Ritchie wrote:We see this sort of question every now and again and I am starting to wonder whether Strings have natural orderings or not.
but all that sort of thing makes me think there isn't one total ordering for Strings at all.
Campbell Ritchie wrote:Remembering that n % 2 == 1 doesn't reliably find odd numbers.
Mike Simmons wrote:. . . the % operator on ints . .
Campbell Ritchie wrote:Has BigInteger got a mod() method? Yes, it has, though I confused myself by looking for BigDecimal at first. I notice that the BigInteger#mod() method doesn't have the problem you would get with n % 2 == 1
15.8.2 Class Literals
A class literal is an expression consisting of the name of a class, interface, array,
or primitive type followed by a ‘.’ and the token class. The type of a class literal
is Class. It evaluates to the Class object for the named type (or for void) as
defined by the defining class loader of the class of the current instance