Skip to content

Instantly share code, notes, and snippets.

@jinahya
Last active March 16, 2016 02:18
Show Gist options
  • Save jinahya/2c7218250dcd4b3fbc40 to your computer and use it in GitHub Desktop.
Save jinahya/2c7218250dcd4b3fbc40 to your computer and use it in GitHub Desktop.
import java.util.logging.Logger;
public enum EnumWithLogger {
//private static Logger logger; // can't place here
NONE {
void world() {
slogger.info("world");
//error: non-static variable ilogger cannot be referenced from a static context
//ilogger.info("world");
}
};
private static Logger slogger;
private EnumWithLogger() {
//error: illegal reference to static field from initializer
//slogger.info("hello");
ilogger.info("hello");
}
private Logger ilogger;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment