Results 1 to 2 of 2

Thread: collection

  1. #1
    D.Calladine is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default collection

    hi i have a department class that has a list of departments and then each department had a list of courses.

    this code in the department class should be able to get the courses depending on the department

    Java Code:
    public Collection<Course> getCourses() { return set.values(); }
    i want to get all these from a collection and put them into an array and display them
    this is the code i've got so far
    Java Code:
    Collection<Department> d = Department.getCollection();
    dept = new Department[d.size()];
    String[] entry = new String[dept.length];
    for (Iterator<Department> iter = d.iterator(); iter. hasNext(); )
    for (int k=0; k<dept.length; k++) {
    dept[k] = iter.next();
    entry[k] = dept[k].getName();
    just wondering how i can alter this code that does it for the departments for the courses.

    any help appreciated

  2. #2
    D.Calladine is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

Similar Threads

  1. Collection Interator
    By wulfgarpro in forum New To Java
    Replies: 1
    Last Post: 09-21-2010, 02:49 AM
  2. help for collection api
    By javastuden in forum New To Java
    Replies: 3
    Last Post: 02-24-2010, 11:52 AM
  3. Collection - java
    By Moonlightkid in forum Advanced Java
    Replies: 3
    Last Post: 09-02-2008, 05:04 AM
  4. how to creat collection
    By STILET in forum Advanced Java
    Replies: 2
    Last Post: 07-29-2008, 07:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •