I think your args in the sub.fun() which must can be cast type of Myclass including args type. I say casttype must be auto.for example int->double vice versa.if args type exist in your SubMyclass then it will run subclass method.it is only a little cue.
Thanks...qingwu<br />When I open my eyes,I see your pretty face.
sorry ,here is a little wrong! now i repaired myclass. your means are the JVM will find the subclass method ,if don`t find. type will be auto to casttype,find parent method! In the first code , the method fun() called in the main(),because JVM don`t find sample arguement's fun() in the subclass method,cast be auto, the type cast to higher.but the parent class method's fun() arguement sample in the main() called. now the JVM don`t know invoke which an indeed fun(); r u means?
overriding isn`t correct? isn't Because the method overriding occurs if the method contains the same method signature including the method name and the parameter list So that it is method overloading. For the method overloading, according to your situation, the method of subclass will do the type casting to be a bigger one(int to long 32-->64) if the subclass can do it,the action will be done if the data size is smaller than the origin.But the action will not be done if data size is bigger than the origin, then,it will search superclass whether contains the same method signature or not. You can test the following