[Solved] Creating two constructors with objects that call to other java files


would suggest you to please follow below approach to initialize your object through argumented construtor.

public class StudentRecord {
   Student stu;
   Address addr;

   public StudentRecord() {
      Student stu;
      Address addr;
   }

   public StudentRecord(String _fName, String _lName, int _id, double _gpa, String _street, String _city, String _state, int _zip){
        this.stu = new Student(_fName, _lName, _id, _gpa);
        this.addr=new Address(_street,_city,_state,_zip);
   }

   public String toString() {
      return String.format(stu + "\n" + addr);
   }
}

As you have already overided toString method in address and student class so you will get the object.

0

solved Creating two constructors with objects that call to other java files