View Single Post
  #1 (permalink)  
Old 08-08-2007, 07:32 AM
lockmac lockmac is offline
Member
 
Join Date: Aug 2007
Posts: 8
lockmac is on a distinguished road
passing an array into an instance
Hi. I am just wandering how do I pass an array from one class into another class via a constructor?

In the class that i collect my information in, I have the following code:

Code:
units[Unit.unitCount] = new Unit(name,code,sem1,sem2,campusCount,campuses);
the name of the array is campuses.

in my Unit class, my Constructor looks like this...

Code:
public Unit(String iName, String iCode, char iSemester1, char iSemester2, int iCampusCount) { name=iName; code=iCode; campuses= new String[10]; semester1=iSemester1; semester2=iSemester2; unitCount++; campusCount=iCampusCount;
but when i try to do a toString to print off values of the array, every value comes up as null, so I can only assume that they are not being set correctly in the first place.

Any help would greatly be appreciated.
Reply With Quote
Sponsored Links