title: parseDouble throwing NullPointerException for a non-null variable
body: <p><br>
  I would love to receive some help from second eyes, for I have struggled to identify what is wrong with my code.<br><br>
  In the Eclipse IDE I am attempting to implement a Google Maps activity that reads seaship MMSI codes from a file in the assets folder  (<i>/assets/mmsi.txt</i>) and adds maps markers to their respective locations. I am able to read from this file using the <code>BufferedReader</code> class but am having problems in converting the resulting <code>String</code> lines to double using the <code>Double.parseDouble</code> function.</p>
  
  <p>LogCat detects the following problems.
  </p>
  
  <pre class="lang-java prettyprint-override"><code>01-23 17:59:11.672: E/AndroidRuntime(18242): FATAL EXCEPTION: main
  01-23 17:59:11.672: E/AndroidRuntime(18242): java.lang.RuntimeException: Unable to resume activity {com.aquamet.saramap/com.aquamet.saramap.MainActivity}: java.lang.NullPointerException
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.os.Handler.dispatchMessage(Handler.java:99)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.os.Looper.loop(Looper.java:123)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.main(ActivityThread.java:4627)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at java.lang.reflect.Method.invokeNative(Native Method)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at java.lang.reflect.Method.invoke(Method.java:521)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at dalvik.system.NativeStart.main(Native Method)
  01-23 17:59:11.672: E/AndroidRuntime(18242): Caused by: java.lang.NullPointerException
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at com.aquamet.saramap.MainActivity.getMMSI(MainActivity.java:173)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at com.aquamet.saramap.MainActivity.setupRegion(MainActivity.java:136)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at com.aquamet.saramap.MainActivity.onResume(MainActivity.java:82)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.Activity.performResume(Activity.java:3827)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
  01-23 17:59:11.672: E/AndroidRuntime(18242):    ... 12 more
  </code></pre>
  
  <p>In other words, there seems to be a NullPointerException in the following code:
  </p>
  
  <pre class="lang-java prettyprint-override"><code>private double[] getMMSI() throws IOException {
          AssetManager am = this.getAssets();
          double[] mmsi = null;
          BufferedReader br = null;
  
          try {
              InputStream  file_stream = am.open("mmsi.txt");
              br = new BufferedReader(new InputStreamReader(file_stream));
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
  
          String line;
          for (int i=0; (line = br.readLine()) != null; i++) {
                  // Following line seems to be the problem (line 173).
                  mmsi[i] = Double.parseDouble(line);
          }
  
          try {
              br.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
  }
  </code></pre>
  
  <p>But, while debugging the variable <code>line</code> is infact not null! (Sorry not enough REP for images)
  <a href="http://i45.tinypic.com/nnqfdz.png" rel="nofollow noreferrer">Debugging Screenshot</a></p>
  
  <p>Another SO user had quite a similar problem, but his variables did seem to be badly initialized.
  <a href="https://stackoverflow.com/questions/13016634/parsedouble-throwing-null-pointer-in-my-code">parseDouble throwing Null Pointer in my code [closed]</a></p>