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.  
  8. class Parcel1 {
  9.  
  10. class Contents {
  11. private int i = 11;
  12. public int value() { return i; }
  13. }
  14.  
  15. class Destination {
  16. private String label;
  17. Destination(String whereTo) {
  18. label = whereTo;
  19. }
  20.  
  21. String readLabel() { return label; }
  22. }
  23. // Using inner classes looks just like
  24. // using any other class, within Parcel1:
  25. public void ship(String dest) {
  26. Contents c = new Contents();
  27. Destination d = new Destination(dest);
  28. System.out.println(d.readLabel());
  29. }
  30.  
  31.  
  32. }
  33.  
  34. class Ideone {
  35. public static void main(String[] args) {
  36. Parcel1 p = new Parcel1();
  37. p.ship("Tasmania");
  38.  
  39. Parcel1.Destination d = p.new Destination("Kansas");
  40.  
  41. }
  42. }
  43.  
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
Tasmania