There are two classes, one is Student
and the other one is Array_list
. There is a problem with the output am not able to understand instead of showing name and sex it shows "Student@9e0bfd"
class Student {
String name;
String sex;
Student(String name String sex)
{
this.name=name;
this.sex=sex;
}
}
SECOND CLASS
import java.util.*;
class Array_list {
public static void main (String args []) {
ArrayList<Student> list=new ArrayList<Student>();
Student s1=new Student("ashish ","male");
list.add(s1);
Iterator itr =list.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
}
}