title: Java variables not initialized error
body: <p>I am getting the following error in my Java program:</p>
  
  <blockquote>
    <p>Java variables not initialized error... error : variable nam and r not
    initialized location class child</p>
  </blockquote>
  
  <p>But <code>nan</code> and <code>r</code> already initialized, yet I am still getting the same error.</p>
  
  <pre><code>public class cla {
      int rn;
      String name;
  
      void get(String a, int x) {
          name = a;
          rn = x;
      }
  
      void display() {
          System.out.println("student name: " + name + "roll no.:" + rn);
      }
  }
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  
  public class child {
      public static void main(String args[]) throws IOException {
          String nam;
          int r;
          BufferedReader bReader = new BufferedReader(new InputStreamReader(
              System.in));
          try {
              System.out.println("enter name and roll no.");
              nam = bReader.readLine();
              r = Integer.parseInt(bReader.readLine());
  
          } catch (Exception e) {
          }
          cla c = new cla();
          c.get(nam, r);
          c.display();
      }
  </code></pre>