-6
public void onClick(View v) {
    String uname=tv1.getText().toString();
    String pass=tv2.getText().toString();
    //String copmare=uname.concat(pass);

    Cursor cur = db.query("accountTable",    // Where are we looking?
        new String[]{ "colProject" },    // What do we want back?
        "colName = ? AND colPass = ?",   // What are we matching?
        new String[]{ uname, pass },     // What to put in the "holes"?
        null, null, null);               // Everything else default...

    if (cur != null) {
        cur.moveToNext();
    }
    return;

    Intent i = new Intent(FirstAssignmentActivity.this,success.class);
    i.putExtra("v1",   cur.getString(0));
    startActivity(i);

}

Why do I have unreachable code?

yoozer8
  • 7,361
  • 7
  • 58
  • 93
irfan
  • 1
  • Eclipse is the IDE. Java is the language. – BoltClock Sep 05 '11 at 05:38
  • I downvoted you for not including error messages, low effort formatting, a lack of detailed description of both code and problem and particularly a lack of documentation of what you tried to fix the problem and where you're stuck. – blkpingu May 09 '18 at 06:31

2 Answers2

2

You write return ;, so control will exit the function at that point and not reach the final 3 lines of the function (Intent i, etc)

thedayturns
  • 9,723
  • 5
  • 33
  • 41
0

You are returning from the method. None of the code after that will execute.

if (cur != null) {
    cur.moveToNext();
}
return;  // AFTER THIS NOTHING WILL EXECUTE 
Nico Huysamen
  • 10,217
  • 9
  • 62
  • 88