Learning Java

By Jonathan Ackerman 1998 
Version 1.0
Next


Welcome to the 'Learning Java' guide. This guide has been designed to gradually upskill you in Java. Each section builds on the knowledge gained in the previous sections, so you should start at the beginning of the guide and work your way to it's end.

The guide is targeted towards people who have done some coding before, but have not done any Java coding.

The guide expects you to have a Java Development Kit (JDK) correctly installed for the O/S you are running and it does not cover the installation of a JDK. All the code in the guide complies with version 1.1 of the Java language specification and the JDK you install should support the JDK version.

Have Fun

Jonathan


Contents

1. Introduction to Java
1.1 What is Java ?
1.2 What can Java do ?
2. Introduction to Object Oriented Programming
2.1 What is Object Oriented Programming ?
2.2 Basic concepts of Object Oriented Programming
2.2.1 Encapsulation
2.2.2 Inheritance
2.2.3 Polymorphism
2.2.4 Classes and Objects
2.3 What are the benefits of Object Oriented Programming ?
3. Java Basics
3.1 Data types
3.2 Statements
3.2.1 if
3.2.2 for
3.2.3 while
3.2.4 do while
3.2.5 switch
3.3 Declaring classes
3.4 The void main method
3.5 The HelloWorld application
3.5.1 The code
3.5.2 Compiling the application
3.5.3 Running the application
3.6 Command line arguments
3.7 Exercise 1: Greetings
4. More on Classes
4.1 Handling Errors - Exceptions and try, catch blocks
4.2 Declaring Attributes
4.3 Exercise 2: Add it Up
4.4 Declaring Methods
4.5 Local Variables and Scope
4.6 Creating Objects
4.7 Better use of the void main Method
4.8 Exercise 3: SimpleCalc
5. Inheritance
5.1 Declaring classes
5.2 Overriding methods
5.3 Overloading methods
5.4 Interfaces
5.5 Type casting
5.6 Exercise 4 : Brain Bender
6. The Java API
6.1 Packages
6.2 The java.lang package
6.2.1 The System class
6.2.2 The String class
6.2.3 The Math class
6.2.4 The Runtime class
6.2.5 The Object class
7. Streams
7.1 What is a stream ?
7.2 The InputStream class
7.3 The OuputStream class
7.4 The FileInputStream class
7.5 Exercise 5: FileDisplayer
7.6 Readers and Writers
7.7 Exercise 6: Average value from input file
8. More Classes from the Java API
8.1 The StringTokenizer class
8.2 The Date class
8.3 The Vector class
8.4 The Hashtable class
8.5 Exercise 7: Average Orders per Day
9. Threads
9.1 What is a thread ?
9.2 The Thread class
9.3 The Runnable interface
9.4 Writing thread safe code
9.5 Exercise 8 :
10. The JDBC
10.1 What is the JDBC
10.2 Connecting to the database
10.3 Executing SQL
10.4 Commits and Rollbacks
11. The AWT
11.1 What is the AWT ?
11.2 Inner classes
11.3 Listeners and Adapters
11.4 Creating a Frame
11.5 Layout managers
11.6 Creating a Menu
11.7 Adding controls to a Frame
11.8 Exercise 9: Simple Editor