Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wrong output?

 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



public class Test7{
public Test7(){}
public Test7(Test7 ref){
this (ref,"Hai");
}
public Test7(Test7 ref,String str){ /***what i thought as a problem***/
ref.Test7(str);
System.out.println("Hi");
}
public void Test7(String str){
System.out.println(str);
}
public static void main(String[] args){
Test7 t = new Test7();
Test7 t7 = new Test7(t);
}
}



/**************question***********/
the output i get is Hai Hi
but according to what i understand it should be a compiler error because there is a constructer which takes two arguments. but there are none passed from main*********/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic