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:
public User[] getUser() {
User[] users = null;
Session session = HibernateUtil.getSessionFactory().openSession();
List<User> users = session.createQuery("from User").list();
for (Iterator<User> 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
}