• Post Reply Bookmark Topic Watch Topic
  • New Topic

For Loop- question  RSS feed

 
Badri Srini
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a program but unable to save it on eclipe getting an error. Need your inputs please

package day1.examples;

public class ExampleFor {

public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i = 0; i <=10; i= i+1);{
System.out.println("value = " + i);
}

}

}

The i which is underlined is giving an error "i cannot be resolved to a variable"
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Badri,
Welcome to CodeRanch!

That's a subtle error. The problem is a stray semicolon. Java sees your code as this:



Whereas you see it as

 
Badri Srini
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne Boyarsky

With my current work schedule.I got few hours free now.So starting to learn java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!