Java is a great language, but it’s missing a feature present in its cousin languages, C++ and C. The feature is the builtin macros __FILE__ and __LINE__. These are often quite useful for debugging, etc. Well, even though Java doesn’t have them as builins, you can still make your own.
public class MacroHack { public static String __FILE__() { return new Throwable().getStackTrace()[1].getFileName(); } public static int __LINE__() { return new Throwable().getStackTrace()[1].getLineNumber(); } }