Java I
Home Up Java I Java II Java III Java IV Java V Java VI Java VII Code

 

J++ 6.0
J++ 1.1
esus
Sun's JDK

The "Hi" Application

Before beginning the development of the Color Belot application, let's first look at a very simple application in order to learn a few of the mechanics of applications.   The simple application will merely print out the message "Hi".  Here it is:

public class HiWorld
{
  public static void main (String [] args)
  {
    System.out.println("Hi");
  }

}

Code Explanation

public class HiWorld  // line 1
{
  // line 2
  public static void main (String [] args)
  {
    System.out.println("Hi"); // line 3
  }
}

It is now time to looks at this application a little bit more closely.  The constructs involved are briefly explained here.  More complete explanations will appear when the Color Belot application is developed.

  1.   Line 1.  "public" indicates that this class is visible to the external world.  "class HiWorld" indicates that there is a Java class named HiWorld.  The information about this class appears between the left brace on the next line down, {, and the right brace at the bottom of the program, }.  Braces are used in Java to delineate related groups of statements.
  2. Line 2. "main" is the name of a method that belongs to class HiWorld.   "public" indicates that the method is visible to the external world.   "static" indicates that all instances of the class Hiworld will share the same copy of the main method.  "void" indicates that the main method is a procedure, as opposed to a function.  All applications must have a "public static void main" method.  This is always the method that is invoked first when the application is run.  The method main has one parameter, "args".   The type of this is parameter is an array of strings, "String []".   For this particular program, the array of strings is not used, but in general, it gives the calling program the option of passing in some parameters to the application.
  3. Line 3.  In the package "System", there is a subpackage called "out".   This subpackage contains a method called "println".  If println is called with a string argument (in this case, "Hi"), it prints the string and then a carriage return.

Environments:

Java is available in many environments.  Find out how to use java in the environment of your choice by clicking on one of the links on the left hand side of this page.