Monday, February 2, 2015

Excercise Solution 1

1. Write a program in java to print or display "Hello World".
class User{
       public static void main(String[] args){
              System.out.println("Hello World");
      }
}

Save the above code into a file, let us say User.java
Compile the source file from the command prompt:
prompt>javac User.java
Now you will have two files, one is your source file User.java and another one is the compiled file namely User.class
Now execute your newly born class as follows and watch the output on next line.
prompt>java User
Hello World

Back to Exercise

1 comment: