Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# +- operator

podonga poron
Ranch Hand
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
Posts: 65278
95
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 ]

podonga poron
Ranch Hand
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
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
Posts: 1374
Eureka !