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;
}
}
No, you have to set it explicitly.
However, many IDEs such as Eclipse allow you to write your field declarations and then autogenerate constructors which set them.
(Note: I would suggest that you make fields
private, and alsofinalwhere possible. Also, avoid underscores in identifiers.)