On Mon, Nov 12, 2001 at 08:48:34AM -0300, Gonzalo A. Diethelm wrote:
> > + public int compareTo(Object je)
> > + {
> > + long obj1Time = this.getNextRuntime();
> > + long obj2Time = ((JobEntry)je).getNextRuntime();
> > + if (obj1Time > obj2Time)
> > + {
> > + return 1;
> > + }
> > + else if (obj1Time < obj2Time)
> > + {
> > + return -1;
> > + }
> > + else
> > + {
> > + return 0;
> > }
> > }
>
> I don't really know much about Comparable, but shouldn't
> this code check against je being null? Something like:
The casting of je to a JobEntry instance handles this implicitly. From
"Effective Java" (p. 55):
"If the argument is not of the appropriate type, the compareTo method should
throw a ClassCastException. If the argument is null, the compareTo method
should throw a NullPointerException. This is precisely the behavior that you
get if you just cast the argument to the correct type and then attempt to
access its members."
--
Christopher Elkins
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>