2

I'm developping an android application so I'm trying to call activity1 "myown" in another activity2 "MainActivity" but I just keep getting an error "Unreachable statement" over this line of code

Intent launchActivity2 = new Intent(MainActivity.this, myown.class); MainActivity.this.startActivity(launchActivity2); Could you explain to me what may went wrong an tell me how to fix it? i would be really grateful

  • Is the above code within an `if` statement? I think more context is needed. – Eugene S Sep 09 '14 at 23:49
  • Can you include the surrounding code then? Specifically the `if` statement and any code that determines its evaluation? – Eugene S Sep 09 '14 at 23:53
  • The problem isn't with this line. It's that this line can't ever be reached, because of what comes before it. A simple example would be: `if (0==1) return;`. The compiler will complain that the `return` statement can't ever be executed because the condition will never be true. – chiastic-security Sep 09 '14 at 23:55
  • in my condition `break;` wasn't in the end of the if statement so it couldn't reach it – Khalil merchaoui Sep 09 '14 at 23:58
  • For the sake of moderating SO, I'll close it as duplicate of [Why does Java have an "unreachable statement" compiler error?](http://stackoverflow.com/questions/3795585/why-does-java-have-an-unreachable-statement-compiler-error) – Andrew T. Sep 10 '14 at 01:55

0 Answers0