This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes +- operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "+- operator" Watch "+- operator" New topic
Author

+- operator

podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
what exatly do the +- operator

example ..

int a = 5;
int b = 2;
int c = a+-b+-b;

c = 1

???
[ June 05, 2008: Message edited by: podonga poron ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Originally posted by podonga poron:
what exatly do the +- operator
+- isn't a single operator. It's the binary plus followed by the unary negation operator.

C= 0 ?? WHY ??
There is no C in your example. Java is case sensitive. If you meant c, then its value is 1.
[ June 05, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
thanks Bear Bibeault !

but i didn't understand, i guest i will have to read more about it .. anyway thanks again !
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
now i understand it

int a = 5;
int b = 2;
int c = a+-b;

c = 3;

because

5+-2
5+(-2)
5-2
3

i leave this resolved for someone that have the same doubt ...
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Eureka !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: +- operator
 
Similar Threads
operators
Primitive Data type Simple Problem
q 19 from ~danchisholmguide mughal/chapter2/exam1.html
byte question
A greenhorn's question concerning method parameters