java - Static Error: This class does not have a static void main method accepting String[]

java – Static Error: This class does not have a static void main method accepting String[]

java – Static Error: This class does not have a static void main method accepting String[]

Any Java class that you run directly must have a main method, which is the entry point, i.e., where the program starts when you execute the code.

public static void main(String args[])

Just rename your method contar() to main(String args[]) and it should work.

Alternate to @mellamokb Answer

public class Caneirinho{

 public static void contar(){
   int i = 1;
   String a =  Carneirinho,
     b =  pulando a cerca.,
     c = s;

   for(i=1; i<=100; i++){
     if(i==1){
       System.out.println( i + a + b );
      } else {     
        System.out.println( i + a + c + b ); 
        Thread.sleep(1000);  // thread wais for 1 sec ie 1000 milisecond    
      }     
    }
  }

public static void main(String[] args){
   contar(); // call contar() from main method
}

}//Carneirinho

java – Static Error: This class does not have a static void main method accepting String[]

If you write a java program, it can have a number of classes but for all the classes to run we should have a main class which is used to implement the classes which we defined. You created a class without main in it. The program will start its execution from main.

Related posts on Static Error  :

Leave a Reply

Your email address will not be published.