This chapter discusses naming and coding conventions as well as reserved words in Java. When you go through this chapter, you'll get some hands-on experience with writing in Java.
14. Finished Program
Answer:
The completed program is given below.
Did you remember to put in the quote marks?
Finished Program
Here is the completed program. Be sure that you put the quote marks where they belong. If you forget just one of them, the compiler will become confused and will not translate your program!
public class Haiku { public static void main ( String[] args ) { System.out.println("On a withered branch"); System.out.println(" A crow has just alighted:"); System.out.println(" Nightfall in autumn."); } } |
public class Haiku{ public static void main(String[] args ) { System.out. println( "On a withered branch"); System . out.println("A crow has just alighted:" ); System.out.println("Nightfall in autumn."); }} |
The compiler does not "see" the two dimensional layout of the program. It regards the program as a stream of characters, one following the other.
However, humans are sensitive to the layout of text, and it is important to be neat and consistent when you create a source file. Although the second version of the program runs correctly, it is much harder for a person to understand.
Question 14:
If there were a slight mistake in the poorly laid-out program, would it be easy to find?