Arslan Ahmed Awan Arslan Ahmed Awan - 1 year ago 216
Java Question

Java _ Cannot Find Symbol Class

I am Write a Program that gets two values from two text fields and calculates their result.

The problem, I am facing is that Java Editor Shows me the following errors.

cannot find symbol class EditText
cannot find symbol class Button
cannot find symbol class string
cannot find symbol class variable integer
cannot find symbol class integer

My Code is .........

public class MainActivity extends AppCompatActivity
EditText firstNumber;
EditText secondNumber;
Button btnAdd;
TextView total;

protected void onCreate(Bundle savedInstanceState)

firstNumber = (EditText)findViewById(;
secondNumber = (EditText)findViewById(;
btnAdd = (Button)findViewById(;
total = (TextView)findViewById(;

public void btnAdd_Click(View view)
string getfirstNumber = firstNumber.getText().toString();
string getsecondNumber = secondNumber.getText().toString();
integer totalResult = integer.parseInt(getfirstNumber) + integer.parseInt(getsecondNumber);
total.setText("Total = " + integer.toString(totalResult));


Answer Source

use following imports

import android.widget.Button;
import android.widget.EditText;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download