• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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.
 
Trust God, but always tether your camel... to this tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic