1
假設我有這個字符串: ,我需要在另一個類內生成一個類嗎? 請任何一個有一個建議這個?**創建一個java類,使用它的源代碼作爲字符串
String sourceCode = "public class Test { " +
"public void myMethod(@Mandatory String s){"+
"System.out.println(\"myMethod : \"+s);}"+
"@SuppressWarnings(\"unused\")"+
"private void mySecondMethod(String s2){"+
"System.out.println(\"mySecondMethod : \"+s2);}"+
"}";
看看這個問題。 http://stackoverflow.com/questions/616532/on-the-fly-in-memory-java-code-compilation-for-java-5-and-java-6 –