Overview

This is an intensive course designed to introduce experienced software developers to Java. The course is primarily aimed at developers who will be moving into Java/JEE from other languages, but it can also be used as a refresher or to consolidate knowledge gained through self-study.

Outline

Core Concepts

  • Origins and goals of the Java language
  • Bytecode and the Java Virtual Machine
  • The classpath environment variable
  • Packages and dynamic class loading

Basic Java Programming

  • Primitive types and literal values
  • Java syntax for binary and numeric literals
  • The difference between reference and value types
  • Converting between strings and numerical types
  • String parsing with the Scanner class
  • Pretty-printing with the Formatter class
  • Performing iteration and selection in Java
  • Java support for strings in switch statements
  • Equality of primitive and reference types
  • Creating and manipulating arrays
  • The costs of String concatenation

Object Oriented Development Part 1

  • Creating basic Java classes
  • Choosing accessibility levels
  • Overloading and overriding methods
  • Overriding the toString method
  • Comparing references using the instanceof operator
  • Comparing references using java.lang.Class objects
  • Inheriting from a base class
  • Creating abstract and final classes

Object Oriented Development Part 2

  • Writing appropriate class constructors
  • Private constructors and singletons
  • Static and instance initialization blocks
  • Top down class and object initialization
  • Declaring and using interfaces
  • Using inner and anonymous classes
  • Implementing equals and hashCode
  • Cloning and copy constructors

Enumerations

  • Why Java historically lacked enum support
  • The typesafe enumeration design pattern
  • How Java 5 baked the pattern into the language
  • The link between enums and classes
  • The java.lang.Enum base class
  • Extending enums with new members
  • Static methods added to enum types
  • New collections which support enums

Annotations

  • Adding metadata to Java code
  • The advantages of annotations
  • Annotations vs configuration files
  • Declaring Java annotation types
  • Understanding meta-annotations
  • Adding methods to annotation types
  • Defining default values for methods
  • Discovering annotations with reflection
  • Writing annotation processors in Java 6

Exception Handling in Java

  • Introducing errors, runtime exceptions and checked exceptions
  • Exceptions in constructors and finalizers
  • Implementing an effective exception handling strategy
  • Using finally blocks properly to perform ‘clean-up’ tasks
  • Java 7 improvements to the try…catch syntax
  • The try-with-resources syntax introduced in Java 7

The Collections API

  • Introducing lists, sets and maps
  • Using iterators and enumerations
  • Choosing the most efficient collection class
  • Specialized collections

Generics in Java Part 1

  • The evolution of Generics in Java
  • Generics as a compile time construct
  • Generics vs templates in C++
  • Comparing Generics and inheritance
  • Working with generic collection classes
  • Introducing the java.lang.Class type
  • Support for Generics in the Reflection API

Generics in Java Part 2

  • Declaring generic classes and methods
  • Type inference when creating generic objects
  • Using the wildcard type in utility methods
  • Defining constraints with bounded wildcards
  • Adding generics to existing Java code

Java Concurrency Pt 1 (The Traditional Model)

  • Creating threads by subclassing
  • Creating threads via Runnable
  • Safely interrupting another thread
  • Synchronized methods and blocks
  • Creating and avoiding deadlock
  • Dangers when synchronizing methods

Java Concurrency Pt 2 (The Modern Model)

  • Lock objects as an alternative to the synchronized keyword
  • Creating threads using Executor objects
  • Storing return values in Future objects
  • Making full use of the ‘thread-friendly’ collection classes
  • The ‘fork-join’ framework introduced in Java 7

Java I/O

  • Introducing input and output streams
  • Introducing readers and writers
  • Using File objects to resolve file paths
  • Text based file I/O with buffered streams
  • Binary based file I/O using data streams
  • Serializing Java objects
  • Customizing Java Serialization

Networking in Java

  • Connecting to servers via Socket objects
  • Creating server loops with ServerSocket
  • Building a simple HTTP web server
  • Load balancing using worker threads
  • Load balancing using asynchronous I/O

Requirements

  • Delegates must be proficient programmers, ideally with several years commercial programming experience