File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "For loop clarification" Watch "For loop clarification" New topic

For loop clarification

Kk Krish

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 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

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()!
I agree. Here's the link:
subject: For loop clarification
It's not a secret anymore!