how can i print a list(employee type) using iterator?
<p>employee class:</p>

<pre><code>public class Employee {

    int empid;
    String name;
    int age;

    public Employee(int empid,String name,int age)
    {
        this.empid=empid;
        this.name=name;
        this.age=age;

    }
    public int getEmpid() {
        return empid;
    }
    public void setEmpid(int empid) {
        this.empid = empid;
    }
    public String getname() {
        return name;
    }
    public void setname(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }



}


comparator class:
public class Employee_comparator implements Comparator&lt;Employee&gt; {


    @Override
    public int compare(Employee object1, Employee object2) {

        return object1.getname().compareTo(object2.getname());
    }
}
</code></pre>

<p>main class:</p>

<pre><code>import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class Employee_Main {

    /**
     * @param args
     */
    public static void main(String[] args) {

        List&lt;Employee&gt; list=new ArrayList&lt;Employee&gt;();

        list.add(new Employee(33186,"varun",23));
        list.add(new Employee(33187,"deepak",23));
        list.add(new Employee(33188,"apple",23));
        list.add(new Employee(33189,"rohan",23));

        Collections.sort(list,new Employee_comparator());

        for(int i=0;i&lt;list.size();i++){

            System.out.print("age:"+list.get(i).getAge());
            System.out.print("empid:"+list.get(i).getEmpid());
            System.out.println("name:"+list.get(i).getname());
        }

        Iterator&lt;Employee&gt; itr=list.iterator();

        while(itr.hasNext())
        {
            System.out.println(itr.next());

        }
    }

}
</code></pre>

<p>when i am printing by using get methos it is working fien but when,
when i am trying to print the elemenst of teh list using iterator,its giving following output:
new_.Employee@28122812new_.Employee@280d280dnew_.Employee@28172817new_.Employee@28082808</p>
