2
2
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with Java Language .......................................................................................... 2
Section 1.1: Creating Your First Java Program ........................................................................................................... 2
Chapter 2: Type Conversion .................................................................................................................................... 7
Section 2.1: Numeric primitive casting ......................................................................................................................... 7
Section 2.2: Basic Numeric Promotion ........................................................................................................................ 7
Section 2.3: Non-numeric primitive casting ................................................................................................................ 7
Section 2.4: Object casting ........................................................................................................................................... 8
Section 2.5: Testing if an object can be cast using instanceof ................................................................................. 8
Chapter 3: Getters and Setters ............................................................................................................................. 9
Section 3.1: Using a setter or getter to implement a constraint ............................................................................... 9
Section 3.2: Why Use Getters and Setters? ................................................................................................................ 9
Section 3.3: Adding Getters and Setters ................................................................................................................... 10
Chapter 4: Reference Data Types .................................................................................................................... 12
Section 4.1: Dereferencing .......................................................................................................................................... 12
Section 4.2: Instantiating a reference type ............................................................................................................... 12
Chapter 5: Java Compiler - 'javac' .................................................................................................................... 13
Section 5.1: The 'javac' command - getting started ................................................................................................ 13
Section 5.2: Compiling for a dierent version of Java ............................................................................................ 15
Chapter 6: Documenting Java Code ................................................................................................................. 17
Section 6.1: Building Javadocs From the Command Line ....................................................................................... 17
Section 6.2: Class Documentation ............................................................................................................................. 17
Section 6.3: Method Documentation ......................................................................................................................... 18
Section 6.4: Package Documentation ....................................................................................................................... 19
Section 6.5: Links ......................................................................................................................................................... 19
Section 6.6: Code snippets inside documentation ................................................................................................... 20
Section 6.7: Field Documentation .............................................................................................................................. 21
Section 6.8: Inline Code Documentation ................................................................................................................... 21
Chapter 7: Command line Argument Processing ....................................................................................... 23
Section 7.1: Argument processing using GWT ToolBase ......................................................................................... 23
Section 7.2: Processing arguments by hand ............................................................................................................ 23
Chapter 8: The Java Command - 'java' and 'javaw' ................................................................................. 26
Section 8.1: Entry point classes .................................................................................................................................. 26
Section 8.2: Troubleshooting the 'java' command .................................................................................................. 26
Section 8.3: Running a Java application with library dependencies ..................................................................... 28
Section 8.4: Java Options ........................................................................................................................................... 29
Section 8.5: Spaces and other special characters in arguments ........................................................................... 30
Section 8.6: Running an executable JAR file ............................................................................................................ 32
Section 8.7: Running a Java applications via a "main" class ................................................................................. 32
Chapter 9: Date Class ............................................................................................................................................... 34
Section 9.1: Convert java.util.Date to java.sql.Date .................................................................................................. 34
Section 9.2: A basic date output ................................................................................................................................ 34
Section 9.3: Java 8 LocalDate and LocalDateTime objects ................................................................................... 35
Section 9.4: Creating a Specific Date ........................................................................................................................ 36
Section 9.5: Converting Date to a certain String format ......................................................................................... 36
Section 9.6: LocalTime ................................................................................................................................................ 37