Home » Android » java – Calculator multiplying is faulty-Exceptionshub

java – Calculator multiplying is faulty-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment


I am trying to build a calculator app, everything works fine but I have problem with multiply operation other basic operations like subtraction and dividing works fine except for multiplying. here’s that bit of the code:

 btn_multiply.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {
                int result = first * second;
                value.setText("" + result); } catch (Exception e)  {
                        "Please fill the blanks with numbers", Toast.LENGTH_SHORT).show();

all other operations are like this but with this bunch of codes active app keep crashing an it doesn’t come up. I have no idea what is wrong.

How to&Answers:

Apparently I used a wrong field name for the button. it’s fixed now. my bad sorry. thanks for your suggestions.