How to create a Class with multiple constructors that use the same parameter type
问题 I am trying to do something like this: public class Arquivo { private File diretorio = null ; public Arquivo(File dir){ this.diretorio = dir; } public Arquivo(String dir){ this( new File(dir) ); } public Arquivo(String fileName){ this( new File("./src/Data/"+fileName) ); } } 回答1: You can't with constructor, that is one of the limitation of constructors time to start using static factory pattern See Also What are static factory methods? 回答2: You can't create two constructors that receive a