Simple System.out Java Program
First of all, you will need a program to run and program java properly (it can be done in notepad, but i dont recommend it) "Ready to Program Java IDE" or "JDK" work fine for this.
CODE
//JavaOut
public class JavaOut
{
public static void main (String [] args)
{
System.out.print("Hello, How are you doing today?");
}
}
The 2 "//" signify a comment, not recognized by the compiler, these comments help you remember what does what, and makes it look nicer, from a programmers point of view. Now the word or sequence of words put after the phrase "public class" has to be the same as the name you save it as, otherwise the program will not run.
public: It must be declared public.
static: It must be declared static because it is being called on the class, not on a specific instance.
void: Its return type is void because it doesn't return a value.
String []args: Its only parameter is a String array that holds optional arguments passed to the class on the java command line.
Those defentitions are straight from
http://java.about.com/library/weekly/aa_methods2.htm Which explains what "public static void main (String [] args)" means, because its been so long since I learned them.
The \"{\" under public class is the "JavaOut" class, one under public class, and "}" at the VERY end.
The 2 \"{\" \"}\" brackets are the main method and go inside the "JavaOut" class, your code goes between this matching set of brackets.
And finally \"System.out.print\" tells java that you want to print out a line of text, or other things, such as integers, and Strings once you get into Scanners and such. If you wish to print out text include it in brackets and quotes: (\"Hello\"); and a semi-colon to end the line of code, which is required for any line of code you print.
With the program written properly, the output on the screen will be "Hello, How are you doing today?"
EXAMPLES:
JavaOut.java
Sunday May 27, 2007 - 1792 reads