February 10, 1998

JavaScript Multi-Dimensional Arrays?

Multi-dimensional arrays can be represented by arrays of arrays. For example, suppose that you want to create a 3×3 matrix, called Brady, and fill it with the strings shown in the following table: col 0 col 1 col 2 row 0 “Marsha” “Carol” “Greg” row 1 “Jan” “Alice” “Peter” row

Many Unhappy I/O Returns

The class java.io.PushbackInputStream in JDK 1.1.3 returns the wrong value from its available() method. If you look at the source code, it returns pos + super.available(); when it should really return (buf.length – pos) + super.available(); I hope I’ve hereby saved you the grief it caused me when implementing some

Stomping the Windows File Bug

This bug workaround identifies Windows operating systems and adds an identifier to the absolute root directory path to avert file problems. File root;String tmp;tmp = System.getProperty(“user.dir”);root = new File(tmp);while((tmp = root.getParent()) != null) root = new File(tmp);// Do this to work around a Win95 bugif(System.getProperty(“os.name”).toLowerCase().startsWith(“win”)) root = new File(root.getAbsolutePath() +

Advantages of automatic storage vs. heap storage

Using operator new (or malloc() in C) to create objects on the heap is expensive in terms of performance (allocating heap memory usually involves a long negotiation with the OS), maintenance (dynamic allocation may fail; extra code to handle such exception is required) and safety (object may be deleted more

delete vs. delete[]

Objects created using new [] must be released using delete [] as in this example. It