java - Why casting the object is redundant -


i have 2 constructors expandable list shown below, , have 1 interface shown below well. want use same expandlist adapter 2 different activities that's why created 2 constructors. problem when initialise constructors, see in 1st constructor when initilaise interface object 2nd parameter in constructor, receive "redundant casting" while in 2nd constructor mandatory initialise interface object 2nd parameter activity should implement interface

please explain why casting in 1st constructor rundant while manadory in 2nd one?

update

both activities extends appcompatactivity 

*code:

public myexpandablelist(context ctx, actmain actmain, arraylist<group> grouplist) {     this.mctx = ctx;     this.mgrouplist = grouplist;     this.mbtutils = new btutils(ctx);     this.mdevdetailsobserver =  (idevicedetailspasser) actmain;//redundant casting, not necessary }  public myexpandablelist(context ctx, actconnect actconnect, arraylist<group> grouplist) {     this.mctx = ctx;     this.mgrouplist = grouplist;     this.mbtutils = new btutils(ctx);     this.mdevdetailsobserver = (idevicedetailspasser) actconnect;//manadory casting  }  //interface public interface idevicedetailspasser { public void ondevicedetailschosen(header header, details details, int grouppos); 

}

seems actmain implements idevicedetailspasser, that's why redundant casting.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -