Core Java Technology Section Index | Page 118
Can I persist my objects using serialization instead of using a relational or object database?
Can I persist my objects using serialization
instead of using a relational or object database?
How should I declare fields within my serializable class to prevent them from being serialized?
How should I declare fields within my
serializable class to prevent them from
being serialized?
Where can I find information about the design decisions made during the development of the Collections Framework?
Sun provides a Design FAQ at http://java.sun.com/products/jdk/1.2/docs/guide/collections/designfaq.html that answers many questions concerning the design of the framework.more
Where can I get the Collections Framework?
The Collections Framework is a core part of the Java 2 platform. You don't have to download anything more than the Java 2 SDK. For more information about the framework, the main documentation is a...more
Which is faster, synchronizing a HashMap or using a Hashtable for thread-safe access?
Because a synchronized HashMap requires an extra method call, a Hashtable is faster for synchronized access.
How do I use an array with the Collections Framework?
The Arrays.asList() method provides a fixed-length List view of an array, where changes to the List are stored in the original array. The Arrays class also provides additional support methods for ...more
How do I create linked lists if there are no pointers?
No pointers does not mean no reference variables. You just can't deference them as you can in C/C++ or perform pointer arithmetic. You can still use abstract data types that require dynamic data s...more
How do you store a primitive data type within a Vector or other collections class?
You need to wrap the primitive data type into one of the wrapper classes found in the java.lang package, like Integer, Float, or Double, as in:
Integer in = new Integer(5);
more
How do I make an array larger?
You cannot directly make an array larger. You must make a new (larger) array and copy the original elements into it, usually with System.arraycopy(). If you find yourself frequently doing this, th...more
The TreeMap documentation states that it is a red-black tree based implementation of the SortedMap interface. What are red-black trees?
A red-black tree is a binary search tree where every node has two children or is a leaf. It ensures O(log N) search times, at a cost of a more complicated insertion (and deletion) process. In a re...more
What newsgroups/mailing lists are available to ask questions about the Collections Framework?
The comp.lang.java.programmer newsgroup is probably your best bet for Collections Framework questions. There is mailing list specific to ObjectSpace JGL-questions that you can subscribe to at http...more
How do I use Enumeration to iterate through a collection?
Enumeration enum = ...;
while (enum.hasMoreElements()) {
Object element = iterator.nextElement();
// process element
}
How do I sort objects into their reverse natural ordering?
The Collections.reverseOrder() method returns a Comparator that sorts objects that implement the Comparable interface in reverse order.
How do I do a case-insensitive string sort in a language-insensitive manner?
You need to use a new Comparator, not the default Comparable. The String class comes with a special Comparator you can use: String.CASE_INSENSITIVE_ORDER.
How do I properly alphabetize (sort) a list of strings in a language-sensitive manner?
This is actually outside the scope of the Collections Framework. Instead, it is part of the java.text package with the Collator and CollationKey classes.
The following example demonstrates this c...more