fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.lang.reflect.Field;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12.  
  13. public static void test(String x) throws java.lang.Exception{
  14. Field f = x.getClass().getDeclaredField("value");
  15. f.setAccessible(true);
  16. String o = "B";
  17. f.set(x, o.toCharArray());
  18. }
  19.  
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. String v = new String("A");
  23.  
  24. System.out.println(v.hashCode());
  25. test(v);
  26. String o = new String("B");
  27.  
  28. System.out.println(v);
  29. System.out.println(v.hashCode());
  30. System.out.println(o);
  31. System.out.println(o.hashCode());
  32.  
  33. }
  34. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
65
B
65
B
66