One Liner...

...tujhe bhi apne pe ye aeitbaar hai ki nahi...

Saturday, April 30, 2011

Query to fetch 2nd highest record.

This query will let you fetch then second highest record from the set of record.

Table struture

Name Type
----------------------------------------- --
ID NUMBER
NAME VARCHAR2(30)
MARKS NUMBER

Query:

select * from student
where marks =
(select max(marks)
from student
where
marks<(select max(marks) from student));

HashSet Vs TreeSet

HashSet:

  • class offers constant time performance for the basic operations (add, remove, contains and size).
  • it does not guarantee that the order of elements will remain constant over time
  • iteration performance depends on the 'initial capacity' and the 'load factor' of the HashSet.
    • It's quite safe to accept default load factor but you may want to specify an initial capacity that's about twice the size to which you expect the set to grow.

TreeSet:

  • guarantees log(n) time cost for the basic operations (add, remove and contains)
  • guarantees that elements of set will be sorted [ascending, natural, or the one specified by you via it's constructor]
  • doesn't offer any tuning parameters for iteration performance
  • offers few handy methods to deal with the ordered set like first(), last(), headSet(), and tailSet() etc

Important points:

  • Both guarantee duplicate-free collection of elements
  • It is generally faster to add elements to the HasSet and then convert the collection to a TreeeSet for a duplicate-free sorted traversal.
  • None of these implementation are synchronized. That is if multiple threads access a set concurrently, and at least one of the threads modifies the set, it must be synchronized externally.
  • LinkedHashSet is in some sense intermediate between HashSet and TreeSet. Implemented as a hash table with a linked list running through it, however it provides insertion-ordered iteration which is not same as sorted traversal guaranteed by TreeSet

Wednesday, April 20, 2011

Quotation

“If you wait to do everything until you're sure it's right, you'll probably never do much of anything.”

- Win Borden

Monday, April 18, 2011

SVN plugin password change in windows(Eclipse)

Please delete folder @ %APPDATA%\Subversion\auth.

Next time when you would commit, it will ask for password.

HashMap Vs HashTable

Main difference is HashMap's are unsynchronized and allows null whereas HashTable's are synchronized and does not allows null(key).