public class HealthInsurancePlan {
//variable for setter & getter method
private double coverage[] = {0.0,0.0};
//setter
public void setCoverage(double coverage[]){
this.coverage = coverage;
}
//getter
public double[] getCoverage() {
return coverage;
}
}
No why following command doesn't work?
What is proper way to fill arguments in the setter method?
setCoverage(0.1,0.2);
Thx.
You can use Java var args so that it accepts variable number of objects and converts it into array of objects. Update your setter as follows:
//setter
public void setCoverage(double... coverage){
this.coverage = coverage;
}
and you can just call setCoverage(0.1,0.2)