Q: java.lang.NumberFormatException and Uncaught handler while parsing doubles Im trying to make a simple counter app for a friend of mine where onClick of a button a total is increased by 1 incrementally. I'm getting a force close when the button is clicked and should be running the math logic. The reason for the errors in the LogCat arent exactly obvious to me. This being the first time I've attempted math in Java/Android(yes Im a novice) I'm not entirely certain that Im handling or declaring the values properly or if its even possible to do it this way. Seen many examples but they all seem to be more complex than what I'm really looking for, nice and simple. As a secondary question (from my research) and for my own verification, a double is a value that can have a decimal whereas int is a whole number? Can they be substituted for one another (use double instead of int and vice versa) so long as they are both whole numbers (ie the double doesnt contain a decimal)? 
The code
    public class CounterActivity extends Activity
{
TextView tt;
Button calculate;
double x=1;  //Known value to be increased by
double z=0;  //The total to increase incrementally
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  tt=(TextView)findViewById(R.id.tt);
  calculate=(Button)findViewById(R.id.calculate);
  calculate.setOnClickListener(OnClickListener);

}

Button.OnClickListener OnClickListener = new Button.OnClickListener() {
  public void onClick (View calculate) {

  x=Double.parseDouble("x");  //Dont believe these are set properly
  z=Double.parseDouble("z");
  z=x+z;  //The basic loop to run onClick
  tt.setText(Double.toString(z));
}
};
} 

The LogCat
    12-16 15:58:52.194: W/dalvikvm(382): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
    12-16 15:58:52.194: E/AndroidRuntime(382): Uncaught handler: thread main exiting due to uncaught exception
    12-16 15:58:52.214: E/AndroidRuntime(382): java.lang.NumberFormatException: 
    12-16 15:58:52.214: E/AndroidRuntime(382):  at org.apache.harmony.luni.util.FloatingPointParser.parseDblImpl(Native Method)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:283)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at java.lang.Double.parseDouble(Double.java:285)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at jtek.industries.com.CounterActivity.calculate(CounterActivity.java:37)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at jtek.industries.com.CounterActivity.access$0(CounterActivity.java:35)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at jtek.industries.com.CounterActivity$1.onClick(CounterActivity.java:33)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at android.view.View.performClick(View.java:2364)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at android.view.View.onTouchEvent(View.java:4179)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
    12-16 15:58:52.214: E/AndroidRuntime(382):  at android.view.View.dispatchTouchEvent(View.java:3709)

A little direction would be appreciated, gotta get the basics down before I can dive into the more complex :)

A: This is wrong:
  x=Double.parseDouble("x");  //Dont believe these are set properly
  z=Double.parseDouble("z");

What parseDouble() method do is converting String given as argument to Double value, so you can't convert "x" to Double. You can put for example "2.5", and that will give you 2.5 as double value. 
More information about this method you can find in Android's documentation

A: Double.parseDouble(someNumber) expects that someNumber is a string representing a number, for example "1.02".
In your case, "x" is not a string representing a number so it fails and throws an exception.
