public enum Singleton {
INSTANCE;
String fromLocation;
String toLocation;
private void initialise(String fromLocation, String toLocation) {
this.fromLocation = fromLocation;
this.toLocation = toLocation;
}
public static void main(String[] args) {
Singleton s = INSTANCE;
s.initialise(args[0],args[1]);
}
}
我似乎无法理解具有普通 Java 类构造函数的语法,我也可以从主例程传递 args。初始化程序对我来说似乎是一种难闻的气味 - 但这是我能想到的最好的。有什么建议么?