class Emily { public static void main ( String[] args ) { System.out.println("A bird came down the walk:"); System.out.println("He did not know I saw;"); System.out.println("He bit an angle-worm in halves"); System.out.println("And ate the fellow, raw."); } }
Usually bugs are much more difficult to find than the one in the previous program. The longer a program is, the more bugs it is likely to have, and the more difficult it is to find them. It is a good idea to practice with short programs where syntax errors and bugs are more easily seen before moving on to longer programs.
Above is a somewhat longer example program.
The program is much like the "Hello World!" program but the
main
method has more
statements inside of it.
Create this program
with a text editor, compile and run it.
(Remember that you can use "copy-and-paste" with your program editor to very quickly create this program.)
Save the program in a file called Emily.java
.
The compiler will create a bytecode file
called Emily.class
.
Each System.out.println
statement
writes out the characters inside the quote marks
on one line:
A bird came down the walk He did not know I saw; He bit an angle-worm in halves And ate the fellow, raw.
Another method,
System.out.print("Some String")
writes out the characters inside the quote marks
and then stops without going on the the next line of the monitor.
Imagine that each println
in the program is changed to print
.
What will the program write?