Start of Tutorial > Start of Trail > Start of Lesson | Search |
Now that you've seen a Java application (and perhaps even compiled and run it), you might be wondering how it works and how similar it is to other Java applications. Remember that a Java application is a standalone Java program-- a program written in the Java language that runs independently of any browser.
Note: If you couldn't care less about Java applications, you're already familiar with object-oriented concepts, and you understand the Java code you've seen so far, feel free to skip ahead to The "Hello World" Applet.This section dissects the "Hello World" application you've already seen. Here, again, is its code:
/** * The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); //Display the string. } }
The "Hello World" application has two blocks of comments. The first block, at the top of the program, uses/**
and*/
delimiters. Later, a line of code is explained with a comment that's marked by//
characters. The Java language supports a third kind of comment, as well -- the familiar C-style comment, which is delimited with/*
and*/
. Comments in Java Code further explains the three forms of comments that the Java language supports.
In the Java language, each method (function) and variable exists within a class or an object (an instance of a class). The Java language does not support global functions or variables. Thus, the skeleton of any Java program is a class definition. Defining a Class gives you more information.
main
Method
The entry point of every Java application is itsmain
method. When you run an application with the Java interpreter, you specify the name of the class that you want to run. The interpreter invokes themain
method defined within that class. Themain
method controls the flow of the program, allocates whatever resources are needed, and runs any other methods that provide the functionality for the application. Themain
Method tells you more.
The other components of a Java application are the supporting objects, classes, methods, and Java language statements that you write to implement the application. Using Classes and Objects introduces you to these components.
Start of Tutorial > Start of Trail > Start of Lesson | Search |