• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code execution  RSS feed

 
Saba Shahrukh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the sequence of execution in a complex code with lots of parenthesis and multiple statements combined into one.
For example System.out.println(int i=0);
 
Greg Brannon
Bartender
Posts: 563
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start here, and then come back with more specific questions.
 
Campbell Ritchie
Marshal
Posts: 56596
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the fact that your code wouldn't compile … it is always left‑to‑right, taking the associativity and precedences of all operators into consideration. Tne Java Language Specification link I gave you shows some unusual cases which explain the outputs.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!