This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "negative integer" Watch "negative integer" New topic
Author

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
Sheriff

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

Joined: Feb 26, 2001
Posts: 6328
    
  15

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: http://aspose.com/file-tools
 
subject: negative integer
 
It's not a secret anymore!