wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compilation error" Watch "compilation error" New topic
Author

compilation error

selvas kumars
Ranch Hand

Joined: Jan 06, 2001
Posts: 115
why this code gives a compilation error??
public static void main(String args[]) {
int j=0;
for(j;j<6;++j)
System.out.println(j);
}
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I think that's because j is not used properly in the initialization clause of the for loop. There has to be some kind of assignment there or nothing...
Val


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi selvas,
The initialization section of the for loop has to be either nothing or a valid expression. Change your code to:

and it will work.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: compilation error