Last active
March 16, 2016 02:18
-
-
Save jinahya/2c7218250dcd4b3fbc40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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