title: Java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
body: <p>Every time I try to start my code I have always the same error:</p>
  
  <pre><code> java.lang.NumberFormatException: For input string: "x"
   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
   at java.lang.Integer.parseInt(Integer.java:492)
   at java.lang.Integer.parseInt(Integer.java:527)
   at Variable.&lt;init&gt;(Variable.java:17)
   at Main.main(Main.java:4)`
  </code></pre>
  
  <p>I put also my code. Can you help me to understand what was wrong?</p>
  
  <pre><code>public class Main {
  
  public static void main(final String[] args) { 
      final Node expression =
        new Plus(
          new Minus(
            new Plus(
              new Variable("x"),
              new Literal(2)
            ),
            new Variable("y")
          ),
          new Minus(
            new Literal(4),
            new Variable("z")
          )
        );
      // an interpreter would just evaluate the expression:
      System.out.println("Expression is: " + expression);
  
      // a compiler would compile the expression into a program
      System.out.println("Compiling expression...");
      final Program program = new Program();
      expression.generateCode(program);
      System.out.println("Resulting program:\n"+program);
  
      // and, later, that program can then be executed after the variables have been assigned
      // First assignment of variables
      VariableSpace variables = new VariableSpace();
      variables.store("x", 5);
      variables.store("y", 7);   
      variables.store("z", 1);
      System.out.println("For x = 5, y = 7 and z = 1 the program executes and returns:");
      int resultOfExecution = program.execute(variables);
      System.out.println(resultOfExecution);
  
      // Second assignment of variables
      variables.store("x", 11);
      variables.store("y", 3);
      variables.store("z", 2);
      System.out.println("For x = 11, y = 3, and z = 2 the program executes and returns:");
      resultOfExecution = program.execute(variables);
      System.out.println(resultOfExecution);        
  }
  
  public class Variable extends Node
  {
      String variable;
      int value;
      /**
      * Constructor for objects of class Variable
      */
      public Variable(final String variable)
      {
          this.variable = variable;
          int value = Integer.parseInt(variable);
      }
  
      public void generateCode(final Program program) {
          program.append(new ILOAD(value));
      }
  
      /**
       * Return a int representing this expression
       * (e.g., new Literal(19).toint() is "19").
       */
        public String toString() {
        return "" + value;
        }
      }
  
  import java.util.ArrayList;
  
  
  /**
   * A Node in an abstract syntax tree (AST)
  * for a very simple expression language.
  * The language only supports the following subtypes of Nodes:
  * &lt;ul&gt;
  * &lt;li&gt;integer values (class Literal)
  * &lt;li&gt;integer variables (class Variables)
  * &lt;li&gt;the integer + operator (class Plus)
  * &lt;li&gt;the integer - operator (class Minus)
  * &lt;/ul&gt;
  * It does not support types other than integers.
  */
  
  public class Node {
  
  /**
   * Compile this AST into an IJVM program:
   * Append instructions to the given Program
   * such that the instructions, when executed
   * produce the same value 
   * as is produced by a call to evaluate(). 
   */
  public void generateCode(Program program) {
  }
  
  /**
   * Generate a string-representation of the subtree.
   * When you implement this method in subclasses,
   * where possible use recursive calls to left.toString() and
   * to right.toString() to do this.
   */
  public String toString() {
      return null;
  }
  
  }
  
  public class ILOAD extends Instruction
  {
  private final int value;
  
  public ILOAD(final int value)
  {
      this.value = value;
  }
  
  public void execute(Storage storage) {
      storage.getStack().push(value);
  }
  
  /**
   * Produce a human-readable String-representation of this instruction.
   */
  public String toString() {
      return "ILAOAD " + value;  
  }
  
  }
  
  import java.util.*;
  
  /**
  * A space that stores the variables during the execution of the IJVM/Java bytecode.
  */
  public class VariableSpace {
  
  private HashMap&lt;String, Integer&gt; value;
  
  public VariableSpace() {
      value = new HashMap&lt;String, Integer&gt;();
  }
  
  public void store(String name, int value) {
      this.value.put(name, value);   
  }
  
  public int load(String name) {
      return value.get(name);
  }
  
  }
  </code></pre>
  
  <p>The problem I have is in the class Variable where I try to convert a String in an Integer because class ILOAD need an integer. I'm so sorry if the code i too long, but the classes are linked each other. Hope you will help me</p>