File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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!