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 :
- c++ – Error: expression cannot be used as a function?
- java – Syntax error, insert … VariableDeclaratorId to complete FormalParameterList
- overriding – Class is not Abstract and does not Override error in Java
- c++ – Error while overloading operator (must be a nonstatic member function)
- c++ – Call to non-static member function without an object argument compiler error
- java – Error – Illegal static declaration in inner class
- error: ISO C++ forbids in-class initialization of non-const static member
- c++ – invalid use of this outside of a non-static member function error?
- Error message Strict standards: Non-static method should not be called statically in php
- C# error: An object reference is required for the non-static field, method, or property