What's wrong with arrays?

Terms

Dynamic data structure
A structure whose "shape" can change as data changes
Static data structure
A structure whose "shape" is fixed upon creation
Vector
A java class which represents a dynamic "array"
ArrayList
A java class which represents a dynamic "array"  (it's more like a list than an array)

Class Notes

Choices for lab on Tuesday
  1. Programming contest - A chance to work in teams to complete the most assignments.  This provides practice in problem solving using a number of different techniques.  (Prizes will be awarded).
  2. Print f - Everything you ever wanted to know about formatting output using the String.format() or printf() methods.  This one helps you to format anything in any way that you wish using a single tool.
  3. Calvin Snowmen - Learn about Applets and launching them on a web site.  
  4. Other ideas??


Followup from the Lab

Important items:
Countries.java
CountryDriver.java



Array List example

An ArrayList (found in the java.util package) is a data structure that provides a dynamic array capability.
http://java.sun.com/javase/6/docs/api/

Methods include:  add, get, clear, clone, remove, isEmpty ...
ArrayListDemo1.java - Basic array list with several items added in sequential order
ArrayListDemo2.java- Demonstrates the toString
ArrayListDemo3.java - Demonstrates removing an item from an ArrayList
ArrayListDemo4.java - Demonstrates inserting an item from the ArrayList
ArrayListDemo5.java - Demonstrates the set method
ArrayListDemo6.java- Casting a generic element with one of a more specific type
ArrayListDemo7.java - Making the ArrayList "type safe"


Vector examples

A Vector (found in the java.util package) is a data structure that provides a dynamic array capability.
http://java.sun.com/javase/6/docs/api/

Methods include:  add, get, clear, clone, remove, isEmpty ...
VectorDemo1.java - Basic array list with several items added in sequential order
VectorDemo2.java- Demonstrates the toString
VectorDemo3.java - Demonstrates removing an item from a Vector
VectorDemo4.java - Demonstrates inserting an item from the Vector
VectorDemo5.java - Demonstrates the set method
VectorDemo6.java- Casting a generic element with one of a more specific type
VectorDemo7.java - Making the Vector "type safe"