This doesn\'t compile and gives the following error : Illegal start of expression
. Why?
public static AppConfig getInstance() {
return mConf
You may write an utility method
public class Util
{
/** Always throws {@link RuntimeException} with the given message */
public static T throwException(String msg)
{
throw new RuntimeException(msg);
}
}
And use it like this:
public static AppConfig getInstance()
{
return mConfig != null ? mConfig : Util. throwException("error");
}