I have a little quiz that I cannot solve by myself. I want to build a program that will print its own source code with java. Anyone knows how to do this? Like this example:
public class SourcePrint {
private static final long serialVersionUID = 1L;
public void test(){
System.out.println("Hi I'm test");
}
public static void main(String[] args) {
new SourcePrint().test();
}
}
when we run this, the output would be same like this:
public class SourcePrint {
private static final long serialVersionUID = 1L;
public void test(){
System.out.println("Hi I'm test");
}
public static void main(String[] args) {
new SourcePrint().test();
}
}
I don't know how to do this. Anybody know the solution or at least the hint? This is not the decompiler, the quiz maker told me the hint is "STATIC".