i got 4 items in HashMap and want to get them stored in an array
<p>I want to retrieve objects stored in <strong>hashmap</strong>, all objects are of same type and want to store them in an array. i tried plenty of things but still not successful:
<strong>Holding is an interface implemented by abstract class AbstractHolding</strong> and further <strong>extended by</strong> two classes <strong>Book and Video</strong> they also implemented the interface which is standard practise. i have stored the items using constructor of both video and book class and its shows the correct length and content while using debugging. i wrote this piece of code ...</p>

<pre><code>public Holding[] getAllHoldings() {
        System.out.println(holdingMap.values().toArray().length);
        Holding[] holding = (Holding[])holdingMap.values().toArray();

        return holding;

    }
</code></pre>

<p>but getting
 [Ljava.lang.Object; cannot be cast to [Llms.model.Holding;</p>

<p>i dont understand when the stored objects are of type Holding then why this casting error occurring...</p>
