I have this Apex class where I have custom objects as defined and debug statements. From the code it seems it is not able to build subObject here.
global class TestApexClass {
global static void buildObject(string fname, string lname) {
Ethnicity e = new Ethnicity('North America', 'Mixed');
System.debug('location: ' + e.location);
MyPersonObject obj = new MyPersonObject(fname, lname, e);
System.debug('personObject: ' + obj);
}
public class MyPersonObject {
public String firstName;
public String lastName;
public Ethnicity e;
public MyPersonObject(String fname, String lname, Ethnicity e) {
firstName = fname; lastName = lname; e = e;
}
}
public class Ethnicity {
public String location;
public String race;
public Ethnicity(String l, String r) {
location = l; race = r;
}
}
}
Here is my debug output: location: North America personObject: MyPersonObject:[e=null, firstName=John, lastName=Doe]
Is there a reason why "e" returns a null value?