9. First Look at Java Code Sample Java Source code: public class HelloJava { public static void main(String args[]) { System.out.println("Hello, Java"); } }
10. Java Code – How It Works? public class HelloJava { public static void main(String args[]){ System.out.println("Hello, Java"); } } Define a class called " HelloJava " Define the main() method – the program entry point Print a text on the console calling the method " println() " of the system's standard output
11. Java Is Case Sensitive! public class HelloJava { public static void Main(String args[]){ system.out.PrintLn("Hello, Java"); } } The keyword class should be lowercase The class System should be in " Pascal Case " The method println() should be in " camel Case " The correct method name is main()
12. Java Code Should Be Well Formatted public class HelloJava { public static void main(String args[]) { System.out.println("Hello, Java"); } } The { symbol should be on the same line. The block after the { symbol should be indented by a TAB Class names should start with a CAPITAL letter The { symbol should be on the same line. The } symbol should be under the beginning of the line with corresponding {
13. Example of Bad Formatting public class HelloJava {public static void main(String args[]){ System.out.println ("Hello, Java"); System.out.println("Hello, Java");} } Such formatting makes the code unreadable