Building dynamic number of arrays to display in Highchart
<p>I am developing a web application at the moment using Java, JS and JDBC. I have some tables with transaction details in my DB which I want to use to display in a HighChart in my JSP. I am able to get a ResultSet of the following table:</p>

<p><a href="https://i.stack.imgur.com/0wVe7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0wVe7.png" alt="enter image description here"></a></p>

<p>Now what I want is to split the data into a number of <code>ArrayList</code>s based on the year and category which I can pass to my HighChart - each <code>ArrayList</code> should have an object containing the year, the category and an array of monthly sales and should look like this </p>

<pre><code>2015 , COLOUR , [1,0,0,6,0,0,0,0,0,0,0,0]

2015 , DESIGN , [2,4,6,0,0,0,0,0,0,0,0,0]

2016 , DESIGN , [0,0,0,5,5,4,7,0,0,0,0,0]

2016 , COLOUR , [0,0,0,5,5,3,6,0,0,0,0,0]
</code></pre>

<p>where the array represents the monthly sales for each year and category (0 would mean there's no sales or no data from DB for that month).</p>

<p>I've been trying to get this right for quite a while now, using iterators and for-loops but I cannot get it working. I am not looking for code, just some ideas and guidance on how to approach this the best way possible cause I'm a bit stuck. </p>