java - Multiple constructors with same arguments -


i need create multiple constructors same arguments can call these dao class populating different drop down values

public static employee emptype(string empcode, string emptype) {      employee emp = new employee();     emp .empcode= empcode;     emp .emptype= emptype;     return emp ; }   public static employee empdept(string deptcode, string deptname) {      employee emp = new employee();     emp .deptcode= deptcode;     emp .deptname= deptname;     return emp ; } 

when referencing dao class, how can refer these constructors?

e.g.

private static employee mylist(resultset resultset) throws sqlexception {     return new <what should here>((resultset.getstring("db_name1")),                        (resultset.getstring("db_name2"))); } 

you cant. also, these functions aren't constructors. , how want decide "constructor" call???

you can merge both functions:

public static employee createemp(string empcode, string emptype, string deptname) {     employee emp = new employee();     emp .empcode= empcode;     emp .emptype= emptype;     emp .deptname= deptname;     return emp ; } 

and use null unneeded argument.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -