Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

+- operator

 
podonga poron
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eureka !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic