Here
are two Java Programming Training Tutorials from
Durham Univerisity. The first one teaches Java fundamentals and
the steps for getting starting programming with Java. The
second Java tutorial below shows you more Java programming features,
such as providing a graphical user interface (GUI) in your
applications, Java's Collections API, and writing Java applets for the
web. These training documents are in pdf format.
Getting
Started with Java Training Tutorial
This
tutorial on Java shows you how to start programming
and developing applications in the Java programming
language. (398kb, 63 pages)
Contents:
1
Introduction
1.1 What is Java?
1.2 How is it executed?
1.3 What are Java
applications?
1.4 What are Java applets?
1.5 APIs
1.6 A digression: what is
JavaScript?
2 Declarations, statements,
input and output
2.1 A simple Java program
2.2 Primitive types
2.3 Declarations and
initializers
2.4 Expressions
2.5 Statements
2.5.1 Blocks
2.5.2 Conditional statements
2.5.3 Looping statements
2.5.4 Other control statements
2.6 Objects
2.6.1 Reference variables
2.6.2 Creating an object
2.6.3
Referring to the fields of an object
2.6.4 Applying methods to an object
2.6.5 Copying objects
2.6.6 Comparing objects
2.6.7
The value null
2.6.8
Garbage collection
2.7 Arrays
2.7.1 Introduction
2.7.2 An array of integers
2.7.3 An array of points
2.7.4
Flexible arrays
2.7.5
Even more flexible arrays
2.8 Methods
2.9 Output and input
2.9.1 Attaching an output stream
2.9.2 Outputting values to the output stream
2.9.3 Closing a file
2.9.4 Attaching an input stream
2.9.5 Reading a line of characters
2.9.6 Reading a value
2.9.7 Handling more than one data item per line
2.9.8 Flushing the output
2.9.9 Dealing with java.io.IOException
2.9.10 JDK Version
1.0.x
i
3 Handling strings
3.1 Creating an object of the class String
3.2 Applying methods to a String object
3.3 The exception StringIndexOutOfBoundsException
3.4 Changing a String object
3.5 Copying String objects
3.6 String
concatenation
3.7 A program
that uses these ideas about Strings
3.8
The class StringBuffer
4
Using classes for data abstraction
4.1 Introduction
4.2 Using a
class declaration to define your own type
4.3 A class called Date
4.4
Stage A: providing a primitive version of the class Date
4.5 Stage B: adding a constructor and a method
declaration
4.5.1 Stage B1: adding a constructor declaration
4.5.2 Stage B2: using a method to display the value of an
object
4.6 Grouping fields and
methods together to implement a type
4.7 Stage C: hiding fields, providing access methods and
toString
4.7.1 Stage C1: hiding the fields and accessing them using
methods
4.7.2 Stage C2: using toString instead of display
4.7.3 Using the default version of toString
4.8 Stage D: providing class variables, class methods and class
constants
4.9 Stage E: the
final version of the Date class
4.9.1 Stage E1: the text of the final version of the Date
class
4.9.2
Stage E2: providing other constructors
4.9.3 Stage E3: defining a method called equals
4.9.4 Stage E4: adding hashCode (to help with using
collections)
4.9.5 Stage E5: using the new version of the Date class
4.10 The role of a class
5
Another example of data abstraction: the class Person
5.1 A class called Person
5.2
Using the class Person
6
Grouping classes into packages
6.1
Package declarations
6.2
Setting the CLASSPATH
6.3
It’s a small world: how can unique names be
generated?
6.4 Compiling from a
private directory into one that is visible from the WWW
7
Object-oriented programming
7.1
Introduction
7.2 Using
inheritance to form a subclass
7.3 A class called Student
7.4
Package members and protected members
7.5
Method overriding
7.6 Using the
class Student
7.7 Dynamic
binding
7.8 Inheritance should
be used for is-a relationships
8
Another example of OO programming: 2D shapes
8.1 The class Shape
8.2 The
class Circle
8.3 The class
Rectangle
8.4 Using the class
Shape and its subclasses
9 Exception
handling
9.1 What is exception handling?
9.2 Altering Date to deal with invalid dates
10
Interfaces
10.1 What is an
interface?
10.2 Producing classes that
conform to an interface
10.3 Using
interfaces
10.4 Other points
11
Starting another thread
11.1 The class
java.lang.Thread
11.2 Deriving the class
ClockStdout from java.lang.Thread
11.3
Using the class ClockStdout in the UseClockStdout program
11.4 Using synchronized for accessing a variable from different
threads
12 Other information about Java
12.1 ITS Guide 108 Advanced Java
12.2
Primary resources
12.3 Important
secondary resources
12.4 Books
Advanced
Java Training Tutorial
This training guide
demonstrates further Java topics. It is 275kb in size and 38
pages in length. It teaches you the following:
- how
to write Java applications containing graphical user interfaces (GUIs)
- how
to manage data collections using the List, Set and Map
interfaces of Java's Collections API
- how
to code Java applets, which are applications that run inside a
browser
Contents:
1
Introduction
2 Providing a graphical user
interface (GUI)
2.1 APIs for producing GUIs
2.2 What the Swing API includes and how it is organised
2.3 A simple example of a GUI
2.4 Stage
A: obtaining the current date and time
2.5 Stage B:
creating a window
2.6 Stage C: adding GUI
components to the window
2.7 Stage D: responding to
a click of the button
2.8 Stage E:
altering the JTextField component
2.9
Stage F: closing the window
2.10
Conclusion
3 The Collections
API
3.1 An introduction to the
Collections API
3.2 The interface List and the
classes ArrayList and LinkedList
3.3 Using the
Iterator interface
3.4 The methods contains,
indexOf, lastIndexof and remove
3.5 An example of a
complete program that manipulates a list
3.6 Conclusion
4 Writing applets
(for use with the WWW)
4.1 Using HTML to
code WWW pages
4.2 Getting Java bytecodes
executed when a WWW page is visited
4.3
Deriving from Applet instead of declaring a main method
4.4 Dealing with the different versions of the Java platform
4.5 Using appletviewer when developing Java applets
4.6 The lifecycle of a Java applet
4.7 Overriding
the init method
4.8 Restrictions imposed
on Java applets
4.9 Reworking an
application as an applet: GetDateApplet
4.10
Producing code that can be used either as an application or an
applet
4.11 Using the Java archive tool
5
Other information about Java