Posts

Showing posts from November 22, 2010

SortedSet Interface

SortedSet Interface -     After making the Set interface, There was a need to make an interface which can hold the elements in natural ordering. And give some extra facilities except to set interface. Then SortedSet was wrote.     SortedSet Interface extends the Set Interface, maintain the sorting in ascending order. SortedSet is generic interface. And Sorted Interface has some extra methods. Comparator  comparator() - This method gives the object of Comparator interface, If any comparator is used for implementing this SortedSet. If SortedSet has natural order then returns null. Object first() - This method is used to return the first (lowest) element from the current set. Object last() - This method is used to return the last (highest) element from the current set. SortedSet subSet(Object start, Object end) -     This method is used to return the SortedSet, include elements those belongs between start and end-1 elements. SortedSet headS...

Equals and = = operator

Image
Equals and = = operator - = = is a operator , which is used for check the equality of two values. if two values are equal then it will return true otherwise return false. equals() is a method of object class, which is used for check the equality of two objects. if two objects are equal then it will return true otherwise return false.      public class Test { public static void main(String[] args) { int int1  = 10; int int2  = 10; Integer one = new Integer(int1); Integer two = new Integer(int2);        //compare for two objects if(one.equals(two)){ System.out.println("two objects are equals"); } // compare two values if(int1 == int2){ System.out.println("Two values are equals"); } } } output : two objects are equals Two values are equals Deep Knowledge about this - in the above figure, I am trying to make a sense about the example -  when we make first int variable int int1=10; value 10...

Recent Post

Recent Posts Widget