[ale] OT, but not as OT as recent stuff (JAVA)

Joseph A Knapka jknapka at earthlink.net
Thu Oct 31 15:05:43 EST 2002


Geoffrey wrote:
> Okay Java gurus, I've come to the conclusion Java was designed to drive 
> you insane whenever you need to convert types. 

You're right there...

 > I'm trying to take two
> java.lang.Objects which are a series of numbers subtract one from the 
> other and store the result in a long value.  I've tried:
> 
> (long)theObject
> (Long)theObject
> Long.parseLong(theObject)

So "theObject" is the result of the subtraction? You need to cast
it to its real class, whatever that may be, and then use that
class's protocol to extract the long value (presumably it will
provide a method for doing so). If it's a Long, then
((Long)theObject).longValue() should do it.

Isn't Java fun? (Apply transformational grammar to arrive at the
correct answer.)

Cheers,

-- Joe


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list