aspose file tools*
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 Java 8 in Action this week in the Java 8 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation error
 
Similar Threads
I/O AGAIN
Inheritance problem
on switch expression
print statement in the declaration ...