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 x-- -x/0?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "x-- -x/0??" Watch "x-- -x/0??" New topic
Author

x-- -x/0??

Ankith suresh
Ranch Hand

Joined: Jun 07, 2007
Posts: 42
Hi,

x---x/0

does it mean x- --x/0 or x-- -x/0???
sankar kandasamy
Greenhorn

Joined: Sep 13, 2007
Posts: 13
x---x/0

Here this statement takes as x-- -x/0
because if i give like this means

int x=10;
int x1=4;
System.out.println("x value:"+(x---x1/2));

the output is 8

here it is a post decrement so it cannot be decrement in this statement
so it takes 10-(4/2) =8

so I conclude this takes as x-- -x/0
Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31
it means x- --x/0, because when i run following code it is giving output 5.

int x=8;
System.out.println("x value:"+(x---x/2));

Output:
x value:5
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424


0 x = 4 y = 5
Matthias Wendel
Greenhorn

Joined: Sep 26, 2007
Posts: 10
It doesn't matter:

Yours,
Matthias
Jan Nowak
Greenhorn

Joined: Aug 12, 2007
Posts: 16
To resolve this example you should know operator precedence, check here. Because x-- have the highest precedence among the given operators it will be evaluated first, then x/0 and then - so the expression
x---x/0 will be:

x-- - x/0

In the example:
int x=8;
System.out.println("x value:"+(x---x/2));

the result is 5 because you have to remember that x-- is a postfix operator and it is applied after the whole expression is evaluated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: x-- -x/0??