QUESTION
Before you do anything else, find out how to compile and run
a Java program in your environment. Some environments provide sample program
similar to the example in Section 1.5.
- Type in the “Hello, world” program, then compile and run it.
- Add a print statement that prints a second message after the “Hello, world!”. Something witty like, “How are you?” Compile and run the program again.
- Add a comment to the program (anywhere), recompile, and run it again. The new comment should not affect the result.
SOLUTION
public class ThinkJava1_Ex2 {
public static void main (String[]args){
System.out.println("Hello, world");
System.out.println("How are you?");
}
}
//This is a comment.
No comments:
Post a Comment