Hi I am thiniking upto now that +,- r binary operators and ++,-- r unary operators. Since a+b (a,b r two operands) ++a (a is a single operand) For this concept i understand like that,But in Mughals book +,- r both unary and binary operators.i get confused. Pl clear my doubt???
Joined: May 10, 2001
Anupama You can use them as either binary or unary. Binary is the traditional x+y and x-y usage. As unary the + re-enforces the fact that the variable/literal is a postive number, it will also promote the operand to an int if it is a byte, short or char.. The - makes an operand negative in value and will also promote to an int if it is a byte short or char. for a more detailed explaination go here: http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#24924 hope that answers your question. Dave [This message has been edited by Dave Vick (edited May 31, 2001).]
Hi Dave,Junilu For this i came to know that operator(+,-) is used for calculating the results for expressions and significance like it is +(positive) r -(Negative). If worng pl correct me.
Joined: Dec 30, 2000
apart from expression calculation they have significance in precedence order too.unary plus/unary minus has higher precedence then binary plus/binaty minus operators. moreover, unary plus/minus have right to left associativity whereas the binary counterpart(i.e. bainary plus/minus) have left to right associativity Hope that helps Lusha