java - Scope of final variable not visible to OnClickListener -
i beginner, i'm trying build calculator. have problem.
i write answer this:
ans += double.parsedouble(etresult.gettext().tostring()); outtest.settext("the answer " + ans); this in onclicklistenter. problem have communicate double ans, defined in beginning of project, if want communicate double need him final, if final cant change him in onclicklistener.
can me , tell me how can this? thanks.
use usual trick: instead of double ans = 0 declare final double[] ans = {0} , you'll able use ans[0] += ... inside handler code.
best post.
ReplyDeletejava online training
java training