How to print out executable code in Java, without executing it?
I want to create a library in Java, so whenever I need to refresh my memory on a certain topic, I can access it immediately just by inputting a certain number. However, once I put the pieces of code into System.out.println(), it takes it as a part of the code and starts spitting out errors. I just need a way to block the execution of a particular part of a code, while still being able to print it. How do I do this? Code: import java.util.Scanner; class MyClass { public static void main(String[ ] args) { int onedotone = 1; Scanner userinput = new Scanner(System.in); int input = 0; input = userinput.nextInt(); if (input == 1) { System.out.println("Overview"); } if (input == 1.1) { System.out.println(class MyClass { //Here is the problem public static void main(String[ ] args) { System.out.println("Hello World"); } } ); } else { System.out.println("Not Found"); } } }