This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
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!