title: Java Variable will not initialize in an if statement?
body: <p>I have initialized and declared the variable "average."  I do not understand why it won't compile.  Does it have to do with the fact that it's in an if else?  I've already tried 
  "|| null" and that is not taking either.  What to do?</p>
  
  <pre><code> // declare variables
      Scanner keyboard = new Scanner (System.in);
      String given;
      String middle;
      String sur;
      String truefalse;
      boolean bool;
      int exam1;
      int exam2;
      int exam3;
      double average;
  
      // get input
      System.out.println("***************  Grade Computer *************");
      System.out.println("Enter the student's first name: ");
      given = keyboard.nextLine();
  
      System.out.println( "Enter the student's middle initial: ");
      middle = keyboard.nextLine();
  
      System.out.println( "Enter the student's last name: ");
      sur = keyboard.nextLine();
  
      System.out.println( "Enter EXAM 1 Grade: ");
      exam1 = keyboard.nextInt();
  
      System.out.println( "Enter EXAM 2 Grade: ");
      exam2 = keyboard.nextInt();
  
      System.out.println( "Enter EXAM 3 Grade: ");
      exam3 = keyboard.nextInt();
  
      keyboard.nextLine();
      System.out.println( "Bonus work completed [true/false]");
      truefalse = keyboard.nextLine();
  
      // adjust exam scores if necesssary
      if (truefalse == "true")
      {
          bool = true;
          exam1 = keyboard.nextInt();
          exam2 = keyboard.nextInt();
          exam3 = keyboard.nextInt();
      }
      else
      {
          average = ((exam1+exam2+exam3)/3);  
      }   
  </code></pre>
  
  <p>Why is the compiler saying
  "variable average might not have been initialized"?</p>