-2
import java.io.*;

class number {
    public static void main(String args[])
    {

        for( int i=1;i<=10;i++);
        {
            System.out.print( i);
        }
    }

the compilation error that keeps occurring is

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    Cannot make a static reference to the non-static field i
Andy Turner
  • 137,514
  • 11
  • 162
  • 243

1 Answers1

1

you have an additional semicolon in your for loop:

import java.io.*;

class number {
    public static void main(String args[]){
        for( int i=1;i<=10;i++){
            System.out.print( i);
        }
    }
}
Mio Bambino
  • 544
  • 3
  • 15