adding Java code for counting inversions