InterviewSolution
| 1. |
What Is Style And Indentation? |
|
Answer» As you write Java programs, you will discover that you have CONSIDERABLE flexibility in how you line your statements and INDENT lines. Some editor programs HELP you line up indented lines and indent NEW BLOCK. If you have already programmed in another language, you probably have your own style of indentation. Java does not impose any specific style, However, you may want to be consistent with your own style and always be conscious that a well-formatted program is easier to read and maintain. For example, the following two programs function equivalently. However, one is much easier to read than the other: import java.applet. * ; public class am_i_readable extends Applet{public void init() { System.out.println("Can you guess whatI do?"); } } import java.applet.*; public class am__i_readable extends Applet { public void init() { System.out.println("Can you guess what I do?"); } }As you write Java programs, you will discover that you have considerable flexibility in how you line your statements and indent lines. Some editor programs help you line up indented lines and indent new block. If you have already programmed in another language, you probably have your own style of indentation. Java does not impose any specific style, However, you may want to be consistent with your own style and always be conscious that a well-formatted program is easier to read and maintain. For example, the following two programs function equivalently. However, one is much easier to read than the other: |
|