wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 4447

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
Similar Threads
Math calculations in JAVA
Negative int
WA #1.....word association
problem with millisecond date calculation
Simple Class, how does this look?