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. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. private static class InnerStatic {
  12. public String toString() {
  13. return "I am static " + this.getClass();
  14. }
  15. }
  16.  
  17. private class InnerNormal {
  18. public String toString() {
  19. return "I am normal " + this.getClass() + " "
  20. + Ideone.this.getClass() + " and " + getName();
  21. }
  22. }
  23.  
  24. private final String name;
  25.  
  26. public Ideone(String name) {
  27. this.name = name;
  28. }
  29.  
  30. public String getName() {
  31. return name;
  32. }
  33.  
  34.  
  35. public static void main (String[] args) throws java.lang.Exception
  36. {
  37. System.out.println(new Ideone("Mat"));
  38. }
  39.  
  40. public String toString() {
  41. return String.format("I am %s '%s'%nwith static: %s%n and normal %s",
  42. this.getClass(), getName(), new InnerStatic(), new InnerNormal());
  43. }
  44. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
I am class Ideone 'Mat'
with static: I am static class Ideone$InnerStatic
 and normal I am normal class Ideone$InnerNormal class Ideone and Mat