This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes deal with loops..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "deal with loops....." Watch "deal with loops....." New topic

deal with loops.....

faiza haris
Ranch Hand

Joined: Oct 17, 2000
Posts: 173
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++)
System.out.println( k + " k after k++, " + m );
if ( i == 2)
System.out.println( k + " m after m++," + m );
System.out.println( k + " outside for loop, " + m );
Bhuvana Dhruva

Joined: Sep 11, 2000
Posts: 28
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.

I agree. Here's the link:
subject: deal with loops.....
It's not a secret anymore!