Question on associativity and precedence
- From: ankur <ankur.a.agarwal@xxxxxxxxx>
- Date: Fri, 4 Jul 2008 12:30:22 -0700 (PDT)
int[] z = {10,20,30,40,50};
int index = 4;
z[index] = index = 2;
System.out.println(z[0]);
System.out.println(z[1]);
System.out.println(z[2]);
System.out.println(z[3]);
System.out.println(z[4]);
This code gives
10
20
30
40
2
Why does it not give:
10
20
2
40
50
Why z[2] is not assigned 2?? How can this be explained in terms of
associativity and precedence rules.
.
- Follow-Ups:
- Re: Question on associativity and precedence
- From: Joshua Cranmer
- Re: Question on associativity and precedence
- From: Roedy Green
- Re: Question on associativity and precedence
- From: Mark Space
- Re: Question on associativity and precedence
- From: Eric Sosman
- Re: Question on associativity and precedence
- Prev by Date: Re: Matching parentheses with Regular Expressions
- Next by Date: Re: Question on associativity and precedence
- Previous by thread: Controlling SoftReferences
- Next by thread: Re: Question on associativity and precedence
- Index(es):