How can we detect redundant rows.and maintain their count.
if the rows are like
11111
11111
10101
11111

the result i want is
11111 4
10101 1

Create a Map with the row values as key and an Integer count as value.
For each row, if that value is already in the map, increment its count. If it's not in the map add it with a count of 1.
You may need some convenient representation for the row values - eg convert the row to a single String

cant it be done with use of 2d array.Actually i have no idea how to use map.

Why not put it in a set?