Beruflich Dokumente
Kultur Dokumente
Lab 1 : CH.1 : Introduction to Java Applications lab document created by Rakan N Al-Enezi
Chapter 1 Objectives:
Create new Java project . Create Class . Write your first program . Run your Program . Modifying your Program .
In Eclipse, create a new Java program: Click File New Java Project from the top menu. An empty white text window should appear in Eclipse.
Recall from lecture: A Java program must be has at least one user-defined class. So for that we need to create class , to create class : Right Click src New Class
1 2// Text-printing program. 3 4public class myfirstapp { 5 6 // main method begins execution of Java application 7 public static void main( String args[] ) 8 { 9 System.out.println( "Hello world!" ); 10 System.out.println( "Welcome to Java Programming!" ); 11 System.out.println( "This is my very first program." ); 12 13 } // end method main 14 15} // end class myfirstapp
We can now test run our program in Eclipse. In the tool-bar, click the Run button as shown in Picture
This should produce some output in the Console window like Console output.
\n \t \" \\
Example:
System.out.println( "I said \"hello\" to Rakan.");