Rabu, 11 Maret 2015

A First Program in Java: Printing a Line of Text

Every time you use a computer, you execute various applications that perform tasks for you. For example, your e-mail application helps you send and receive e-mail, and your web browser lets you view web pages from websites around the world. Computer programmers create such applications by writing computer programs. A Java application is a computer program that executes when you use the java com- mand to launch the Java Virtual Machine (JVM). Let us consider a simple application that displays a line of text. (Later in this section we will discuss how to compile and run an application.) The program and its output are shown in Fig. 2.1. The output appears in the light blue box at the end of the program. The program illustrates several important Java language features. Java uses notations that may look strange to nonprogrammers. In addi- tion, for your convenience, each program we present in this book includes line numbers, which are not part of actual Java programs. We will soon see that line 9 does the real work of the program—namely, displaying the phrase Welcome to Java Programming! on the screen. We now consider each line of the program in order.


1  // Fig. 2.1: Welcome1.java 
2  // Text-printing program. 

4  public class Welcome1  
5  { 
6  // main method begins execution of Java application 
7  public static void main( String args[] ) 
8   { 
9    System.out.println( "Welcome to Java Programming!" ); 
10 
11  } // end method main 
12 
13 } // end class Welcome1
Output:



That is maybe the simple code of Java Code Programming. 
I hope you can understand every code.

0 komentar:

Posting Komentar