Getting a object reference in interface that was not passed

Currently, the below code gives compile erorr, because the listener don't know whats smsTask. I would need a instance of the smsTask in the listener. Is it possible to do this **without** passing it in the contruntor? It seems redunant if I do: .createTask(smsTask,new TaskCompleteListener(smsTask){...} current code: public void doStuff(){ SmartPhoneTask smsTask=createSmsTask(); super.getSystem().createTask(smsTask,new TaskCompleteListener(){ @Override public void onTaskComplete() { releaseResources(smsTask);//error. }}); } private SmartPhoneTask createSmsTask() { return new SmartPhoneTask(); } createTask: void createTask(SmartPhoneTask task, TaskCompleteListener listener);

以上就是Getting a object reference in interface that was not passed的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准