-5

After some time I tested this simple code and still I had errors.

The errors that I got on this example was the following: line 4 cannot resolve method a. Line 6:first: ';' expected,second: Expression expected,third: Variable 'a' is never used.

So I don't get it. Whatever I try I get errors. I even downloaded some code in java from an IntelliJ developer and when I pasted on my editor I still got errors with methods and even the System.out.println. I tried to write in Eclipse but even there I got errors. Please help. I want so much to study but I am getting frustrated with these things.

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

     a();
      static void a() {
          System.out.println("asdfff");
      }
   }
}
khelwood
  • 55,782
  • 14
  • 81
  • 108
  • 4
    you put a function in a method: this is illegal in Java; my advice is to step back and begin with some basic tutorial – fantaghirocco Mar 29 '19 at 14:54

1 Answers1

0

Just get your a() method declaration out of the main :

public class asdf {

    public static  void main(String[] args) { 
       a();
    }

    static void a() {
       System.out.println("asdfff");
    }  
}
nullPointer
  • 4,419
  • 1
  • 15
  • 27