Videos
Because it has no main() method where the code would take the starting point. Use this
public class HelloWorldClass {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Please note there are some of the things you should always take a note of while programming. Which is also known as the syntax of the language.
Java requires you to have the class written as the FileName, HelloWorldClass is the name of the file of yours.
Then, any data type of it. In my case it is void which means it won't return anything to you in the end.
Also, you should write String[] args which is the Parameter to the method. I was last night trying to understand why I should write these? There is a method, which runs without these, but Java recommends you to add the parameters.
When running Java you need a main method so the compiler knows what to run:
public class HelloWorldClass {
public static void main(String[] args)
{
System.out.println("Hello world!");
}
}