CIS 260 (Java II) Demonstration Programs
Input and output
- IOapalooza1.java: keyboard as BufferedReader
- IOapalooza2.java: keyboard using Scanner class
- IOapalooza3.java: I/O using JOptionPanes
- IOapalooza4.java: using a complex JOptionPane
- IOapalooza5.java: using a full-blown GUI
- IOapalooza6.java: making the GUI into its own object
- IOapalooza7.java: DecimalFormat class
- IOapalooza8.java: printf method, Formatter class, format method
- Scanner1.java: Scanner class and static import
- TestPrintf.java: Formatter class and printf() method
Text and binary file I/O
- SimpleFileIO.java: reads and writes text files
- int1to100.txt: used as input file for SimpleFileIO.java
- Course.java: a basic class use with the UseCourse programs
- FileInfo.java: demonstrates File class
- UseCourse.java: sequential file output using Formatter class
- UseCourse2.java: variation of UseCourse.java
- UseCourse3.java: reads data files created by UseCourse.java and UseCourse2.java
- SerialTest.java: reads/writes objects from/to files using Serializable interface
- RandomTest.java: demonstrates random access file techniques
- RandomTest2.java: variation of RandomTest.java that
converts Unicode characters to byte values to save space
- Binary01.java: writes and then reads binary data in a file
- Binary02.java: writes and then reads binary data in a file using a class for the record to make life easier
- Binary03.java: binary file access using seek (random access)
- ReadBinaryNIO2.java: reading a binary file using NIO2 techniques
- CreateData02.java: program used to create binary data file from a text file with population data
Layout managers and GUIs
- TestCardLayout1.java: CardLayout demonstration with previous and next buttons
- TestCardLayout2.java: CardLayout demonstration with direct access buttons
- TestGridBagLayout1.java: basic GridBagLayout
- TestGridBagLayout2.java: GridBagLayout using insets
- TestGridBagLayout3.java: GridBagLayout using gridwidth and gridheight
- TestGridBagLayout4.java: GridBagLayout using fill
- TestGridBagLayout5.java: GridBagLayout using weightx and weighty
- TestGridBagLayout6.java: GridBagLayout with no fill and larger frame size
- TestGridBagLayout7.java: GridBagLayout using anchor points
- TestGridBagLayout8.java: GridBagLayout using ipadx and ipady
- TestDesktop.java: demonstration of JDesktopPane holding JInternalFrames
- TestTabbedPane.java: demonstration of a tabbed interface using JTabbedPane
- TestViewer.java: a work in progress at the school demonstrating how to launch an
external application from a Java application
- TestToggleButtons.java: checkboxes and radio buttons
- TestListWidgets.java: JList and JComboBox
- GUI demonstration (Binary calculator)
- Ed.java: text editor demonstrating GUI components
Collections: Vector, ArrayList, HashMap, LinkedList
- TestVector.java: demonstrates the Vector class
- Coll1.java: demonstrates the Vector class
- Coll2.java: demonstrates the HashMap class
- Coll3.java: demonstrates how to use an Iterator
- TestArrayList.java: demonstrates an ArrayList
- TestLinkedList.java: demonstrates a LinkedList
- TestHashtable.java: demonstrates a HashTable
- TArray0.java: interactive unordered array manipulator
- TArray1.java: interactive ordered array manipulator
Arrays (includes collections and iterators)
- TestArrays.java: demo of Arrays and Collections
- TestSync.java: demonstrates how List objects can change underlying array
- TestEnumeration1.java: creating and using an Enumeration object
- TestIterator1.java: using an Iterator
- TestIterator2.java: using a ListIterator
- Array0.java: using "String[] args" to get command line arguments (CIS 160)
- Array1.java: basic array usage; passing arrays to methods (CIS 160)
- Array2.java: reading array data from a file; dealing with partially filled arrays (CIS 160)
- Array3.java: processing file data before saving it in an array;
using methods to process data (CIS 160)
- Array4.java: reading parallel arrays from file (CIS 160)
- Array5.java: linear searching of arrays; using parallel arrays (CIS 160)
- Array6.java: sorting parallel arrays (CIS 160)
- Array7.java: using arrays of objects (CIS 160)
- Array8.java: using the Arrays class to sort an array of objects
array8data.txt: data file for Array8.java (make sure after transferring
data file that there is no blank line after last record and theat each record is on its own line) (CIS 160)
- Array9.java: reading an indeterminate number of items into an array with error checking (CIS 160)
- SortArray1.java: use Array class to sort an array of Integer objects
- SortArray2.java: use Array class to sort an array of ints
- SortArray3.java: use Array class and a custom Comparator to do
a customized sort of an array of objects
- MultiDim1.java: multidimensional array demonstration
Class, interface, inheritance, composition
- Course.java: demonstrates a basic class
- TestClass.java: demonstrates some basic class concepts
- Drawable.java: an interface that contracts for a draw method
- Point.java: a simple class that specifies a point on a 2D grid
- Shape.java: an abstract class the implements Drawable, and contains
a Point
- Circle.java: a subclass of Shape that implements Shape's abstract methods
- Rectangle.java: a subclass of Shape that implements Shape's abstract methods
- TestShapes.java: an Applet that tests out the classes and interface used
for this demonstration
- TestShapes2.java: the JApplet version of TestShapes.java
Recursion
- Recurse.java: various recursion algorithms (CIS 160)
- Recurse.java: demonstration of recursion
- RecursiveSearch.java: recursion isn't always a good thing
Searching, and sorting
- Search.java: linear and binary searching (CIS 160)
- RecursiveSearch.java: recursion isn't always a good thing
- Sort.java: various sorting algorithms (CIS 160)
- Sort2.java: demonstration of sorting techniques with timings
- DemoHeapSort.java: demonstration of heap sort
- DemoHeapSortG.java: demonstration of heap sort using generics
- DemoHeapSortG2.java: demonstration of heap sort using generics (with a demonstration class)
- DemoQuickSort.java: demonstration of recursive quicksort using generics
- DemoQuickSort2.java: demonstration of iterative quicksort using generics
- RevisedQuicksort.java: a better Quicksort algorithm to base changes on [obsolete]
- Sort.java: class that implements a quicksort on an array of objects [obsolete]
- TestSort.java: test program for Sort class [obsolete]
- TestHeap.java: demonstration of a heap sort [obsolete]
Variable argument lists, autoboxing, assertions, JavaDoc
- VarArgs1.java: using variable argument lists
- VarArgs2.java: using variable argument lists
- VarArgs3.java: using variable argument lists
- AutoBox1.java: demonstrates Java 1.5's new autoboxing feature
- TestAssert1.java: default assertion
- TestAssert2.java: assertion with custom message
- TestJavadoc.java: demo of automated Java documentation feature
Multithreading demonstrations
- TThread0.java: the problem
- TThread1.java: sleep doesn't solve the problem; it just slows everything down
- TThread2.java: creating threads
- TThread3.java: using threads
- TThread4.java: the Runnable interface
- TThread5.java: shared resource problems I
- TThread6.java: shared resource problems II (reorganized)
- TThread7.java: synchronized methods
- TThread8.java: synchronized code blocks
- TThread9.java: the wait() method
- TThreadA.java: the notify method()
- TThread5b.java: new finer grained locking available in Java 1.5
- HorseRace.java: a simulation with numerous threads
Strings and Regular expressions
- RegEx1.java: basic regex demo
- RegEx2.java: interactive regex demo
2cities.html: text file for RegEx2 program
- RegEx3.java: another regex demo
- Tokenize.java: demonstrates an easy way to tokenize a string
- FindLinks.java: finds links in web pages online
- Tokenize.java: demonstrates StringTokenizer (no regex)
- dict.txt: dictionary of words used with Chapter16a and Chapter16b programs
(from SIL
International's website)
- Chapter16a.java: uses String.matches and regex
- Chapter16b.java: Files.readAllLines, and the String
methods startsWith, endsWith, and indexOf
- Chapter16c.java: uses several static Character class methods
- Chapter16d.java: demonstrates the StringBuilder class
- Chapter16e.java: two ways to tokenize a String
- Chapter16f.java: demonstrates String.replace with regex
Data structures
- TStack0.java: interactive stack manipulator
- TQueue0.java: interactive queue manipulator
- TQueue1.java: interactive circular queue manipulator
- LList.java: implementation of a linked list
(TestLList.java: test driver for LList class)
- LinkedList.java: implementation of a linked list using generics
(TestLL.java: test driver for LinkedList class)
- GTestLinkedList.java: linked list class using generics
- MyStack.java (simple stack class) ·
TMyStack.java (driver)
- MyGStack.java (generic stack class) ·
TMyGStack1.java (driver 1) ·
TMyGStack2.java (driver 2)
- MyGQueue.java (generic queue class) ·
TMyGQueue1.java (driver 1) ·
TMyGQueue2.java (driver 2)
- MyGDQueue.java (double ended queue) ·
TMyGDQueue1.java (test driver)
- GTestStack.java: stack class using generics
- GTestQueue.java: queue class using generics
- BST.java: implementation of a binary tree class using generics
- Countable.java: Countable interface for use with BST.java
- TestBST.java: Test driver for BST.java
- TestGraph.java: graph code demonstration
Various topics
- Deprecated1.java: using deprecated methods (won't compile)
- Deprecated2.java: deprecated methods replaced (from Deprecated1.java)
- FullSpec.java: ommitting import statement and using full class specification
- ImportStatic.java: an example of using a static import
- TestForIn.java: deonstration of new "for/in" loop
- Banner.txt: demonstrates how to create a package
- NewPage.java: applet which loads new web page
NewPage.html
- NewPage2.java: applet which loads new web page - HTML tag
specifies that code is stored in an archive (jar) file
NewPage2.html
- TestPlugin.java: Java Plugin test
TestPlugin.html
- TestParam.java: getting parameters from web page
TestParameter.html
- Brutus.java: brute force approach to 4-queens problem