my dog learned polymorphism
The moose likes Java in General and the fly likes Test for negative long? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Test for negative long?" Watch "Test for negative long?" New topic

Test for negative long?

myron schabe

Joined: Aug 21, 2002
Posts: 19
How can I test if a long is a negative rather than positive value?
Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
Check to see if the long is less than zero.
long myLong = -5L;
System.out.println(myLong < 0);
Prints "true" if negative.
Prints "false" if positive.

Hope This Helps
I agree. Here's the link:
subject: Test for negative long?
It's not a secret anymore!