
|
|
Magercises:
Java Basics
Introduction
These Magercises show how to create and run Java
applications and applets, use strings and arrays in Java,
how to create simple classes and methods, and how to
create packages. Details about the semantics of equality
and assignment in Java are also explored.
There are eight Magercises to complete:
- Hello World
Application
Type in a "Hello World" application
from the course notes, compile it using the javac
compiler and run it using java, the Java
interpreter. Educational goal(s):
- Compile and run a Java application
- Applet
Parameters
Modify the previous applet to print out its
parameters. Educational goal(s):
- Use of the APPLET and PARAM
tags in HTML.
- Reading of applet parameters.
- Reference
Semantics in Java
Some details of reference semantics in Java are
explored by creating one-to-one relationships
between some objects. Educational goal(s):
- How objects are referenced in Java.
- How maintain referential integrity
between objects.
- Equality in Java
Examine the semantics of equality in Java by
performing searches on an array of objects. Educational
goal(s):
- Semantics of == and the equals
method.
- Garbage Collection in
Action
Watch Java's garbage collector reclaim storage.Educational
goal(s):
- learn under what circumstances Java
performs garbage collection.
- learn that finalizers are not guaranteed
to run.
- learn how to force garbage collection.
- Working With Strings
Learn how to do common string manipulations in
Java. Educational goal(s):
- Create new strings using concatenation.
- Use of String constructors.
- Use of the substring method.
- Use of StringBuffers.
- Conversion of basic types into Strings.
- Conversion of Strings into
numeric datatypes.
- Working With Arrays
Create some arrays and and show how to do common
array tasks. Educational goal(s):
- Iterate through arrays.
- Use the arraycopy method to copy
arrays efficiently.
- Creation and initialization of arrays.
- The Hashtable Class
The array used for storage in previous magercises
is replaced with a Hashtable. Educational
goal(s):
- Use of the Hashtable class.
- Iteration using the Enumeration
interface.
|