- Java and JSP
Understanding public static void main
public class HelloWorld
public static void main(String args)
In recently being enrolled in Computer Science (trying to gain experience in java), I don't quite understand the meaning of the code after public class, and how it interacts with displaying the line of code with
. Rather, wouldn't it be more simpler just to display the main string and letting the system display the text itself?
||09-06-2012 10:58 PM
I don't understand your question.
System.out.println is required in order to print out text to the screen in Java CLI. You cannot just place "Hello World" on a line and have it displayed on the screen.
public static void main(String argv) is required. This is the entrance method to the application, and at least one main method is required in order to execute the application. When you create a jar, you can specify which class' main method will be the application entrance point. Calling java does not allow you to specify what method is called, so therefore you must call java on an entire class which resolves the main method as the entrance. This is the same in a lot of lanauges; C# and C both have the main methods, and languages like PHP use dummy main() in any userspace code not blocked into a function.
function HelloWorld(). So anyways you would need something to fill the hole in, as what the code you stated before would do.
|All times are GMT +1. The time now is 03:27 PM.
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.