+ 5
Can't I use int main() in java?
recently I observed using int main() with return 0 shows an error in Java
2 ответов
+ 3
in java it has to be void.
the return in main() in other programming languages returns a value to check the status of the exit.
in java you can use System.exit()
+ 1
Can the main() method in Java return any data? No. main() always has void as its return type. The reason is whenever a method has a return type other than void then the value returned must be stored in a memory location in the invoking method.
In Java programs, the point from where the program starts its execution or simply the entry point of Java programs is the main() method. Hence, it is one of the most important methods of Java and having proper understanding of it is very important.
class GeeksforGeeks {
public static void main(String[] args)
{
System.out.println("I am a Geek");
}
}
If you to learn and make career as Java developer then go through here: https://www.cetpainfotech.com/technology/java-training