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 negative integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "negative integer" Watch "negative integer" New topic

negative integer

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Is it possible to turn a positive int or Integer into a negative value of the same amount eg. +60 into -60?
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
Multiply by -1.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

the unary - operator does it:

Integer is a wrapper class and is immutable. You'd have to do something like this:

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link:
subject: negative integer
It's not a secret anymore!