/JavaHelloWorld

This is the classic Hello World program in Java.

Primary LanguageJava

Java Hello World

This Java file contains the classic Hello World program in Java. Try tinkering with the code in the following ways to see what happens.

  1. Change the class from HelloWorld to helloworld. Recompile. What happens? Change it back. 2. It gives an error
  2. In the line containing System.out.println("Hello, world!");, try leaving out a quotation mark or the semi-colon. Recompile. What happens? Change it back. 3. It gives an error
  3. Try manipulating the "Hello, World!" String to say something else. Recompile. 4. The output chamges
  4. Based on your knowledge of programming, add the following line before the System.out.println(). String name = "Sam"; Try to get the line to print out what the value of name is. Notice that in Java, we need to declare the types of variables. 6. The output changes to sam