package examples; /** * CS 401 Hello World Example * *

This simple example shows the the basic structure of a Java program. *

*

Comments in Java come in a couple different flavors. Documentation * comments, like this one, are placed at specific places in a .java file to * provide documentation for other programmers who intend to use your software. * A utility, called JavaDoc, can process your .java file and use these comments * to automatically generate HTML pages that describe the operation of each * class, field, and method. Special tags, like the \@author one below, provide * this utility with special tagged information.

* *

Multi-line comments differ in that they start with /* instead of /** and * end with the same asterisk, *, followed by a forward slash, /. These comments * are usually used for long descriptions of implementation details.

* *

Single line comments start with two forward slashes, //, the text after * which is ignored until the end of the current line. * * @author PJ Dillon */ public class HelloWorld //All Java code must exist as part of a class even if { //we're not yet programming with objects. We'll cover //this soon /** * The execution of every Java program begins in the main() method (function) * of one class in your program. We'll discuss the meaning of the keywords * later. For now just remember the syntax of the method. It must be written * exactly the same in all of your projects. * * @param args */ public static void main(String[] args) { /* Like most languages, Java reserves a number of words that have a specific meaning, called keywords, and cannot be used as identifiers anywhere else in a java program. Keywords shown here include 'public', 'class', 'static', 'void', and 'int'. Identifiers are user defined variables in a program. In this program, they're 'HelloWorld', 'args', 'myVariable', and 'main'. */ int myVariable; System.out.println("Hello World!!!!"); /* * This program simply prints the string of characters 'Hello World!!!!' out * to the terminal window. The code makes use of software already provided * by Java, particularly a class called 'System' that contains a predefined * object called 'out' on which we call the method 'println' to PRINT a LiNe * of text to the screen. This will become more clear when we discuss * object-oriented programming. For now, remember the syntax for how to * print information to the screen. */ } }