我正在尝试做这样的事情:
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) );
}
}
你不能使用构造函数,这是构造函数的限制之一
开始使用的时间静态工厂模式 http://en.wikipedia.org/wiki/Factory_method_pattern
See Also
- 什么是静态工厂方法? https://stackoverflow.com/questions/929021/what-are-static-factory-methods-in-java
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)