It’s a calculator app, when i click foreg. 9, i get null pointer exceptions at the lines with stars. What could be going wrong? I’m just a beginner.
nine.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
String con= input.getText().toString();
handlenumber("9",con); **
}
private void handlenumber(String number,String com) **
{
number=new String();
com=new String();
if(com.equals("0") || com.equals("") || r!=0){
input.setText(number); **
r=0;
}
else
{
input.setText(com.concat(number));
}
}
From what you showed it seems like
inputis null, make sure you initialize it / assign to it.Also, you have two parameters passed to
handlenumber, don’t reassign to them use them. e.g. remove the lines: