• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

operatots

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i am having problem with this code
class abc{
public static void main(String args[]){
int i=0;
int []a={3,6};
a[i]=i=9;
System.out.println(i+""+a[0]+""+a[1]);
}
}
as the assignment operator works from right to left ,this shud give arrayout of bound error.But it runs smoothly!!
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Puneet,
The array access expression is evaluated before the assignment of 9 to i.
Jerry
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Puneet
The assignment operator works from left to right. First any variable on left need to complete before you assign the left value. Read JSL.
Answer: a[0] = i = 9; , So it will print 996
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic