Bassicly i want to print 1 then 2 then 3 then 4 incrementing when the user presses the next button - but it shows a warning on i++ saying its a "Dead Code", this is how i usually do for statements so im not sure whats going on. Any guidance would be appreciated
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.one:
break;
case R.id.Next:
for(int i=1; i<11; i++){
info.setText(""+i);
break;
}
You're getting a "Dead Code" issue because your
info.setText(""+i);
break;
After you setText() the first time, you break, unconditionally. Therefore it will never get the chance to increment i, and that's where the dead code is.
I think it's likely that the issue here is a mis-placed }
You probably want the break within the case, rather than within the for-loop?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.