fork download
  1. class Foo
  2. {
  3. String s;
  4. int i;
  5. public Foo(){
  6. this("Kumagai");
  7. }
  8. public Foo(String s){
  9. this(s,1);
  10. }
  11. public Foo(String s,int i){
  12. this.s = s;
  13. this.i = i;
  14. System.out.println("String:" + this.s);
  15. System.out.println("int:" + this.i);
  16. }
  17. }
  18.  
  19. class Sample{
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. System.out.println("Foo()の呼び出し-------------------------");
  23. Foo f1 = new Foo();
  24.  
  25. System.out.println("Foo(\"Hey\")の呼び出し-------------------------");
  26. Foo f2 = new Foo("Hey");
  27.  
  28. System.out.println("Foo(\"Bye\",200)の呼び出し-------------------------");
  29. Foo f3 = new Foo("Bye",200);
  30. }
  31. }
Success #stdin #stdout 0.15s 57500KB
stdin
Standard input is empty
stdout
Foo()の呼び出し-------------------------
String:Kumagai
int:1
Foo("Hey")の呼び出し-------------------------
String:Hey
int:1
Foo("Bye",200)の呼び出し-------------------------
String:Bye
int:200