Cut and paste the following into Ready to Program.
//name: A. Grate Programme
//date: Sept 15
//purpose: a starting program, shows output
public class Starter
{
public static void main (String args [])
{
new Starter ();
}
public Starter ()
{
System.out.println ("Hello World!");
}
}
Hit the "Run" button.
A window should appear that has the words "Hello World" in it.
Here is an explanation of the parts of the program:
| class | A class goes around methods. They hold all of the code in a program. |
| Starter | This is the name of your program. You must save your file as "Starter.java" |
| public static void main (String args []) | This is a method. Methods go inside classes. They hold the instructions to the computer. |
| System.out.println ("Hello World"); | This is how you print a message on the computer screen. You put what you want printed in quotes. |
A Direct Translation,
word for word. (Translation in italics)
public class Starter
anything can use this I'm starting a program now It's called Starter.
{
Begin my program
public static void main (String args [])
anything can use this RUN THIS PART
{
Begin main
new Starter ();
make a new window Run the code in the Starter method in it;
}
End main
public Starter ()
anything can use this This is Starter's code ()
{
Begin Starter Code
System.out.println ("Hello World!");
Print this on the screen: "Hello World!"
}
End Starter Code
}
End my program
System.out.println ("a\"a");
System.out.println ("a\\a");
System.out.println ("a\na");
System.out.println ("a\ta");