-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
  • 131,952
  • 11
  • 151
  • 228

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
  • 497
  • 3
  • 12