File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Unary Operator () Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unary Operator ()" Watch "Unary Operator ()" New topic
Author

Unary Operator ()

Paul Callaly
Greenhorn

Joined: Dec 16, 2003
Posts: 12
Hi
Bit of a Programming 101 question but what does the unary operator () do?
The following list might also be helpful for people studying for the test
Thanx, Paul
Unary operators are: ++ -- + - ! ~ ()
Arithmetic operators are: * / % + -
Shift operators are: << >> >>>
Comparison operators are: < <= > >= instanceof == !=
Bitwise operators are: & ^ |
Short-circuit operators are: && ||
Conditional operators are: ?:
Assignment operators are: = "op="
Yuriy Grechukhin
Ranch Hand

Joined: Jan 16, 2004
Posts: 41
I don't know if () is considered an operator, but if it is, I would say it returns unchanged value of what's inside it.
Consider this:
7++ evaluates to 8
5+6 evaluates to 11
Cat instanceof Animal evaluates to true
b = 5 evaluates to 5 (can be checked by a = b = 5, a will be 5 as well)
so since all those expressions evaluate to something (an we consider parantheses an operator) whatever is inside the () will evaluate to itself:
(5) returns 5
[ March 04, 2004: Message edited by: Yuriy Grechukhin ]

The sword of destiny has two blades, one of them is you.
S Anand
Greenhorn

Joined: Feb 23, 2004
Posts: 11
Hi Paul
I don't think () is considered as an operator.
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Originally posted by S Anand:
Hi Paul
I don't think () is considered as an operator.

I think it is a casting operator. Example follows...

Also for object casting too...
Hope this helps.
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
hi,
you have postfix() like in a method/constructor: aMethod() Aconstructor()
and you can have cast: (type)e
post fix is higher in precedence than the unary operators, and cast is lower than unary.
is this what you meant?
Davy


How simple does it have to be???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unary Operator ()