SE450: Example: Hello World [28/41] Previous pageContentsNext page

There are two main types of Java programs, applications and applets. We will be developing all (or almost all) applications in this course.

An example application

        // Filename: Hello.java
        /**
        * A Java application that prints the message: "Hello from Venus!"
        */
        public class Hello {
            public static void main (String[] args) {
                System.out.println("Hello from Venus!");
                /* System.out refers to the standard output */
            }
        }
        

Let's break down this program:

Filename - The filename must match the class name for the class in the file. Only one public class is allowed per file.

The first document is a javadoc comment. The Javadoc tool will be discussed shortly. Javadoc comments start with /** instead of just /*

The class name is Hello. It is public

It has one method. Static and other method modifiers will be discussed soon

Java can use two non-javadoc comment blocks: /* comment */ and // comment

Previous pageContentsNext page