algorithms in java

Type safe Collection checkedCollection()

JDK 1.5 adds a feature called generics to JDK 1.2 collection classes. With generics, it is possible to add only one type of data to a data structure. But the legacy classes, introduced with JDK 1.0, like Vector or Hashtable do not have this opportunity. To overcome this, the Collections class comes with checkedCollection() method …

Type safe Collection checkedCollection() Read More »

Singleton List with singletonList()

What is singleton? With singleton class, you can create only one object. If another object is tried to create, the JVM throws UnsupportedOperationException. A Singleton class contains only one element. If tried to add a second element, the add() method throws UnsupportedOperationException. Singleton class limits the developer from instantiating more than one object. This idea …

Singleton List with singletonList() Read More »