Welcome to JavaRanch. Please UseCodeTags when you post source code.
Sharma Vinit wrote:HashMap map=null;
But i am getting a nullPointerException at the line in red (map[i] = new HashMap();)
Ofcourse, because map is null. You need to initialise it first:
Note that arrays have a fixed size once they are created. In your code, you probably don't know beforehand how many entries the array should get (since you're reading rows from a ResultSet). Use a collection class instead of an array, for example an ArrayList - because that can be resized dynamically. Convert it to an array afterwards if needed: