0

Is there any easy way to create constructors from private variables
from

public class Vehicle {
public String VehicleNo;//  AQP 4300
public String Model;    //Toyota Vitz
public String ChassisNo;//  AE-09-8E-104N
public String EngineNo;//   AE-0097-EW3
public String DateReg;//    24/04/2006
public String Mileage;//    80,345
}

TO THIS PARAMETERIZED CONSTRUCTOR

public class Vehicle {
public String VehicleNo;//  AQP 4300
public String Model;    //Toyota Vitz
public String ChassisNo;//  AE-09-8E-104N
public String EngineNo;//   AE-0097-EW3
public String DateReg;//    24/04/2006
public String Mileage;//    80,345

public Vehicle(String VehicleNo,String Model,String ChassisNo,String EngineNo,String DateReg,String Mileage){
    this.ChassisNo=ChassisNo;
    this.DateReg=DateReg;
    this.EngineNo=EngineNo;
    this.Mileage=Mileage;
    this.Model=Model;
    this.VehicleNo=VehicleNo;
}
2
Contributors
1
Reply
8
Views
1 Year
Discussion Span
Last Post by JamesCherrill
1

Yes

Right click in the editor
Insert Code...
Constructor...
click the fields you want to include as parameters

Edited by JamesCherrill

Votes + Comments
Obvious ;)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.