aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "for loop" Watch "for loop" New topic

for loop

srilavanyaa subramanian

Joined: May 30, 2006
Posts: 26
could any one explain me the logic behind this code....i just want to know how the nested loop is wrking
public static void main(String args[])
int c = 0;
A: for(int i = 0; i < 2; i++)
B: for(int j = 0; j < 2; j++)
C: for(int k = 0; k < 3; k++)
if(k>j) break;
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi ranchers,

the magical word is indentation of your



all events occur in real time
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
To understand such loops insert System.out.println statements at interesting places in your program. Print out the variables at those stages.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Have you tried LearnNowOnline?
subject: for loop