I want to pass array as a parameter of object but I am kind of stack. So here is my problem.
public class Publisher {
public static void main(String args[]) {
String teachers[] = {"Jyothi", "Jyostna", "Sumathi"};
Publisher2 p1 = new Publisher2(teachers[1],20); //The problem is here, I can't specify
//index of array (I can put onlu teachers without index[1])so toString method is returning address of object instead of the name
System.out.println(p1);
}
}
class Publisher2 {
String[] teachers;
int y;
public Publisher2(String[] teachers, int y) {
this.teachers = teachers;
this.y = y;
}
@Override
public String toString() {
return "Publisher2{" + "teachers=" + teachers + ", y=" + y + '}';
}
}