Optimize java code to find the mirror image of binary tree.

two check the two tree are mirror image or not. isMirrorImage function will take two tree root node reference and return boolean value true of false depends upon the mirror image.   public boolean isMirrorImage(Node firstTree, Node secondTree){        if(firstTree == null && secondTree ==null){            return true;        }        if(firstTree ==null || secondTree == null ){                 return…

Details

How to use an Iterator ?

Often, you will want to cycle through the elements in a collection. For example, you might want to display each element. The easiest way to do this is to employ an iterator, which is an object that implements either the Iterator or the ListIterator interface. Iterator enables you to cycle through a collection, obtaining or…

Details

Java Uses- Collections Framework

Prior to Java 2, Java provided ad hoc classes such as Dictionary, Vector, Stack, and Properties to store and manipulate groups of objects. Although these classes were quite useful, they lacked a central, unifying theme. Thus, the way that you used Vector was different from the way that you used Properties. The collections framework was…

Details

The Properties

Properties is a subclass of Hashtable. It is used to maintain lists of values in which the key is a String and the value is also a String.

The Properties class is used by many other Java classes. For example, it is the type of object returned by System.getProperties( ) when obtaining environmental values.

The Dictionary

The Dictionary class is an abstract class that defines a data structure for mapping keys to values. This is useful in cases where you want to be able to access data via a particular key rather than an integer index. Since the Dictionary class is abstract, it provides only the framework for a key-mapped data…

Details

The Vector

The Vector class is similar to a traditional Java array, except that it can grow as necessary to accommodate new elements. Like an array, elements of a Vector object can be accessed via an index into the vector. The nice thing about using the Vector class is that you don’t have to worry about setting…

Details

The Enumeration

The Enumeration interface isn’t itself a data structure, but it is very important within the context of other data structures. The Enumeration interface defines a means to retrieve successive elements from a data structure. For example, Enumeration defines a method called nextElement that is used to get the next element in a data structure that…

Details

Java Uses – Data Structures

The data structures provided by the Java utility package are very powerful and perform a wide range of functions. These data structures consist of the following interface and classes: Enumeration BitSet Vector Stack Dictionary Hashtable Properties All these classes are now legacy and Java-2 has introduced a new framework called Collections Framework, which is discussed…

Details