A.2 Your First Program in Java: Printing a Line of Text

A Java application is a computer program that executes when you use the java command to launch the Java Virtual Machine (JVM).First we consider a simple application that displays a line of text. Figure A.1 shows the program followed by a box that displays its output.

Fig. A.1 Text-printing program

Computer code and output. The code has 11 lines.

Commenting Your Programs

We insert comments to document programs and improve their readability. The Java compiler ignores comments, so they do not cause the computer to perform any action when the program is run.

The comment in line 1


// Fig. A. 1: Welcome1.java ...

Get Android How to Program, 3/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.