Forums Register Login

deal with loops.....

+Pie Number of slices to send: Send
What is the easiest way to get the answer for the following code??? Since we�ll be short of time , how is it best to work out this problem and find the result values? write on paper or???
class Testjranch
{
public static void main(String args[ ] )
{
int k = 0;
int m = 0;
for ( int i = 0; i <= 3; i++)
{
k++;
System.out.println( k + " k after k++, " + m );
if ( i == 2)
{
continue;
}
m++;
System.out.println( k + " m after m++," + m );
}
System.out.println( k + " outside for loop, " + m );
}
}
+Pie Number of slices to send: Send
hi,
i think the best way is to work it out on paper. i don't think that u will lose much time in that and also can reduce errors, things will be more clear.
bhuvana
permaculture is giving a gift to your future self. After reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 604 times.
Similar Threads
Increment Test
simple class
Question from jqplus
what is the Output? and why?
Initialization
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:58:01.