I'm writing a quick little program right now, and unfortunately it has to be written in java, which I have never used before. I have a class called University, and a driver program which is supposed to instantiate an instance of the University class. However, I want to pass an array of objects to the University class. Here is what I'm trying:
I get a compiler error: "cannot resolve symbol - constructor University (Employee[])"
Is it even possible to pass an array of objects to a new instance of a class through the constructor? I really wish I knew what I was doing.
public class University implements java.io.Serializable
{
Employee[] employees = new Employee[8];
public void University(Employee[] args)
{
employees = args;
}
}
public class ProgExc4
{
public static void main(String[] args)
{
Employee[] employees = new Employee[8]; // array of 8 Employee objects that bsu needs to know about
University bsu = new University(employees); // error here
University updatedBSU = new University(employees);
....
}
I get a compiler error: "cannot resolve symbol - constructor University (Employee[])"
Is it even possible to pass an array of objects to a new instance of a class through the constructor? I really wish I knew what I was doing.