• 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

confused with o/p

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Somebody explain me this code:



I haven't stated o/p for you to guess.

Thanks
[ April 18, 2005: Message edited by: Kalyani Marathe ]
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ... The output should have been given and even if you dont give, people are smart enough to run the code and give you the output to act smarter )

Anyways ... long time after SCJP for me ... lemme try!

Output is "Total 0";

The very first time the for-loop condition fails .... I went in the first go without checking it as I was too busy to answer this ... it may be wrong ....By the way ... It is always better to give the output and what you expected so that we will be fully aware about your doubt before explaining you the solution!

Cheers!
_Mani
 
Kalyani Marathe
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you please clarify why this(line below) isn't printing?

System.out.println(" i = " + i + " : j = " + j);

Thanks.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can you please clarify why this(line below) isn't printing?

System.out.println(" i = " + i + " : j = " + j);



Execution never enters the loop, since total > 30 fails straight away (total = 0).

Try it with total < 30.

nimai
 
Kalyani Marathe
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I got now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic