App shurting down when button clicked : I have this code I have written in android project to open a  new view but whenever the button is clicked, the app stops working but returns no error on the debugger console
what could I be doing wrong?

Here is my code

        public class LoginActivity extends Activity{
            private Button btnLinkToRegister;
            btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen);  
   
         // Link to Register Screen
        btnLinkToRegister.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                Intent i = new Intent(getApplicationContext(),
                        RegisterActivity.class);
                startActivity(i);
                finish();
            }
        });
}

I have removed other codes to make it easy to identify the problem