Is it possible to set class variables by simply instantiating the class with parameters for the constructor function?
Psuedo code
public class Employee {
String first_name;
String last_name; // can this be set automatically from the parameter of the constructor function without having to explicitly set it?
public Employee (String firstName, String lastName) {
first_name = firstName; // is there a way to avoid having to type this?
last_name = lastName;
}
}
String first_name = "John";) but you need to somehow instruct the JVM how to assign the values to the fields (you might want to swap the ctor arguments, right?)public Employeenotpublic function Employee.