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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "For loop clarification" Watch "For loop clarification" New topic
Author

For loop clarification

Kk Krish
Greenhorn

Joined: Sep 28, 2010
Posts: 9
HI frndz,
having a doubt in for loop .Shal we declare like this .
for(int i=0;i<=5;(intArray[i] == 3)break;i++).
Theoritically i no that we cant.Please Suggest me y we cant.
Here instead of break please use continue also...no pbms
Is it possible in java/c in some other languages? Thanks in advance
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Please use clear and simple English. No short cuts
Matthew Raw
Ranch Hand

Joined: Nov 30, 2010
Posts: 76

Hello,
this code you wrote is a nonsense. The for loop in Java consists of three parts:
1. the initial statement
2. the condition, under which the the code can proceed with the itetration
3. the iteration expression
You have four expressions there, so the code will not compile.
You can rewrite your loop to this form in order to compile:
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

My Advise : UseRealWords


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Abimaran Kugathasan wrote:My Advise : UseRealWords


I think you meant "Use Real Words" as 'UseRealWords' is not a real word !


be a well encapsulated person, don't expose your privates, unless you public void getWife()!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: For loop clarification