Counting number of pairs in an integer array
There are couple of improvement possible in your code.

In this method setMapAndReturnCount you should change the declaration of map from,

Map&lt;String, Object&gt; mapCount = new HashMap&lt;String, Object&gt;();


to

Map&lt;Integer, Integer&gt; mapCount = new HashMap&lt;Integer, Integer&gt;();


As you know, you want to store the input array numbers as key in Map and value is the count of occurence of a particular number in the array.

By using Object class as value in Map, you are defeating one of the main purpose of having generics implementation in Java. If you use Object then you need to uselessly cast, and otherwise don't have to.

Another point in same method, you can write your for loop in a better way like this, instead of your current code which does double work of first checking through containsKey and then uses mapCount.get to again pick the value of key.

public int setMapAndReturnCount(int[] sockArr) {
    Map&lt;Integer, Integer&gt; mapCount = new HashMap&lt;Integer, Integer&gt;();
    for (int j = 0; j &lt; sockArr.length; j++) {
        Integer count = mapCount.get(sockArr[j]);
        if (count == null) {
            mapCount.put(sockArr[j], 1);
        } else {
            mapCount.put(sockArr[j], count + 1);
        }
    }
    return returnCount(mapCount);
}


Similarly, you can change returnCount method to this,

public int returnCount(Map&lt;Integer, Integer&gt; mapCount) {
    int count = 0;
    for (Integer value : mapCount.values()) {
        count += (value / 2);
    }
    return count;
}


As you don't need to first iterate on keySet and then retrieve the values with get which will be slower, and instead just iterate it on values as that is what you need for calculating number of pairs, which will be relatively faster.

Also, if you are using Java-8 and above,

You can change your returnCount to one liner like this,

public int returnCount(Map&lt;Integer, Integer&gt; mapCount) {
    return mapCount.values().stream().mapToInt(x -&gt; x / 2).sum();
}