当我尝试编译下面的代码时,我收到错误“构造函数调用必须是构造函数中的第一个语句”。我收到错误在线this(text, style, font, colour, backgroundBitmap);
单身人员类没有编译
Im不在构造函数内,即时只是试图从初始化方法调用它。
public class TimerLabelFieldSingleton extends TimerLabelField{
private TimerLabelFieldSingleton ref;
private TimerLabelFieldSingleton(Object text, long style, Font font,
int colour, Bitmap backgroundBitmap) {
super(text, style, font, colour, backgroundBitmap);
}
private void initialise(Object text, long style, Font font,int colour, Bitmap backgroundBitmap){
this(text, style, font, colour, backgroundBitmap);
}
public TimerLabelFieldSingleton getSingletonObject(Object text, long style, Font font,int colour, Bitmap backgroundBitmap){
if(ref == null){
ref = new TimerLabelFieldSingleton(text, style, font,colour, backgroundBitmap);
}
return ref;
}
}
刚才已经意识到,被调用getSingletonObject何时发生初始化。感谢您的回答 –
这是一个语法错误。 – umbr