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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. CBox box=new CBox(2,3,4,"blue");
  13. box.show();
  14. }
  15. }
  16.  
  17. class CBox
  18. {
  19. private int length;
  20. private int width;
  21. private int height;
  22. private CColor cr;
  23.  
  24. public CBox(int l, int w, int h, String col)
  25. {
  26. length=l;
  27. width=w;
  28. height=h;
  29. cr=new CColor(col);
  30. }
  31.  
  32. class CColor
  33. {
  34. private String color;
  35.  
  36. public CColor(String clr)
  37. {
  38. color=clr;
  39. }
  40.  
  41. public void show_color()
  42. {
  43. System.out.println("color : "+color);
  44. }
  45. }
  46.  
  47. public void show()
  48. {
  49. System.out.println("lenght : "+length);
  50. System.out.println("width : "+width);
  51. System.out.println("height : "+height);
  52. cr.show_color();
  53. }
  54. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
lenght : 2
width : 3
height : 4
color : blue