At 08:31 PM 4/26/00 -0700, you wrote:
>Hi,
>
>Sorry to post this silly doubt here, but I need
>experts' answers, and I dont find experts anywhere
>other than here.
>
>Accoring to Core Java and other books :
>
>1. Unary operators have higher precedence that
>multiplication/division operators.
>
>2. Associativity of unary operator is from right to
>left.
>
>In light of this, can anybody explain the output of
>the following program :
>
>public static void main(String args[]){
>
> int a = 1;
> int b = 1;
> a = a++ * ++a;
> b = ++b * b++;
> System.out.println(a);
> System.out.println(b);
>}
Result is:
3
4
My head thinks of it like this:
a = a++ * ++a
a= 1 * ++a ....where a is currently equal to 2
a= 1 * 3
a=3
b=++b * b++
b=2 * b++ .....where b is currently equal to 2
b=2 * 2
b=4
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets