Alternate way for comparison call back function?
Comparator

There is no need for your interface.... what's wrong with Comparator? Why do you need to have your own?

The reason you appear to have it is because you need to compare the myTreeItem against another myTreeItem and the generic type is not right for you, but you can solve it easily with wrapping the Comparator in your myTree class when you need to....

So, your code has:


tree1.setCallback(new comparableCallBack&lt;Integer&gt;() {
        public int onCompare(myTreeItem&lt;Integer&gt; item1,
                myTreeItem&lt;Integer&gt; item2) {
            .......
        }
    });



but it should instead have:

tree1.setCallback(new Comparator&lt;Integer&gt;() {
        public int compare(Integer item1, Integer item2) {
            .......
        }
    });


and then, your library should have it's own private Comparator that looks something like:

class TreeComparator &lt;T&gt; implements Comparator&lt;myTreeItem&lt;T&gt;&gt; {

     private final Comparator&lt;T&gt; delegate;
     TreeComparator(Comparator&lt;T&gt; delegate) {
         this.delegate = delegate;
     }
     public int compare(myTreeItem&lt;T&gt; a, myTreeItem&lt;T&gt; b) {
         return delegate.compare(a.getItem(), b.getItem());
     }
}


Code Style

Read the Java Code-style guidelines.

Java class names should start with a capital letter.