Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Saving the Finished Product

Your program should now resemble Listing 2.2, although you might have used slightly different spacing in Lines 5–6. Make any corrections that are needed and save the file (by choosing File, Save).

LISTING 2.2 The Finished Version of the Saluton Program

 1: package com.java24hours;
 2:
 3: class Saluton {
 4:     public static void main(String[] arguments) {
 5:         String greeting = "Saluton mondo!";
 6:         System.out.println(greeting);
 7:     }
 8: }

When the computer runs this program, it runs each of the statements in the main statement block on Lines 5 and 6. Listing 2.3 shows what the program would look like if it was written in the English language instead of Java.

LISTING 2.3 A Line-by-Line Breakdown of the Saluton Program

 1: Put this program in the com.java24hours package.
 2:
 3: The Saluton program begins here:
 4:     The main part of the program begins here:
 5:         Store the text "Saluton mondo!" in a String variable named greeting
 6:         Display the contents of the variable greeting
 7:     The main part of the program ends here.
 8: The Saluton program ends here.

Listing 2.4 shows what the program would look like if written in Klingon, the language of the warrior race from Star Trek.

LISTING 2.4 The Saluton Program in Klingon

 1: This program belongs to the house of com.java2hours!
 2:
 3: Begin the Saluton program here if you know what's good for you!
 4:     The main part of the program begins here with honor!
 5:         Store the gibberish "Saluton mondo!" in a String variable called greeting!
 6:         Display this gibberish from a tongue inferior to Klingon!
 7:     End the main part of the program here to avoid my wrath!
 8: End the Saluton program now and be grateful you were spared!
  • + Share This
  • 🔖 Save To Your Account