Below is a simple program which outputs Hello World! Open a new BlueJ project and copy the following into a class called HelloWorld. Compile and run it to make sure it works.
/** * This program writes: Hello World! * * @author (Haas) * @version (V1 Fall 2006) */ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
Assignment: Create a program to print out a picture of a simple house (see below). NOTE: You will need to use the escape character "\"
Escape Sequence |
Character |
|
\n |
newline |
|
\t |
tab |
|
\" |
" (double quote) |
|
\' |
' (single quote) |
|
\\ |
\ (back slash) |
/\ / \ / \ ------ " " " " " " "----"