How to convert a List of Object type to an array of objects
<p>I have to return array of objects from a method. The objects are initially held in a List of objects type. I am having difficulties in assigning values from list of objects to array of objects. How do I do that. Here is my code:</p>

<pre><code>public User[] getUser() {

    User[] users = null;

    Session session = HibernateUtil.getSessionFactory().openSession();
    List&lt;User&gt; users = session.createQuery("from User").list();
    for (Iterator&lt;User&gt; iter = users.iterator(); iter.hasNext(); ) {
        User user = iter.next();
        //Here I need to assign User type object from list to array of objects
    }
    return users; // returning nothing so far
}
</code></pre>
