• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt about assignments

 
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i have a doubt regarding below program
class Prog
{
public static void main(String[] args)
{
int a,b,c,d;
a=b=c=d=100;
a+=b*=c/=d%=20;
System.out.println("a......."+a+"b.........."+b+"c.........."+c+"d........."+d);
}
}
i got a=1320,b=1210,c=11,d=10
so, what is the values of a,b,c,d and please explain the a+=b*=c/=d%=20; equation assignment process
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harivenkatesh Polnati wrote:
i got a=1320,b=1210,c=11,d=10
so, what is the values of a,b,c,d and please explain the a+=b*=c/=d%=20; equation assignment process


It doesn't look like you actually ran this code, did you? You can break this down into its equivalent:

Note that evaluation starts from the right and proceeds to the left. What you have is fundamentally a series of assignment statements so the order of precedence of math operators does not come into play here.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic