aspose file tools
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 1Z0-808 this week in the OCAJP forum!
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: 5345

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]
Consider Paul's rocket mass heater.
subject: negative integer