有没有办法在我们自己的程序中访问String常量池的内容?
假设我有一些基本代码可以做到这一点:
String str1 = "foo";
String str2 = "bar";
Run Code Online (Sandbox Code Playgroud)
现在我们的String常量池中有两个字符串浮动.有没有办法访问池并打印出上述值或获取池中当前包含的当前元素总数?
即
StringConstantPool pool = new StringConstantPool();
System.out.println(pool.getSize()); // etc
Run Code Online (Sandbox Code Playgroud)