NullPointerException using arrays
<p>I have in one activity:</p>

<pre><code>...
double []mylab=new double [100];

public void compute(){
             ...
             double mytime=Double.parseDouble(timing.getText().toString().trim());
             //fill array
             for (int i=0;i&lt;=mytime;i++){

                 mylab[i]=Math.exp(i);
                 //Arrays.fill(mylab,Math.exp(i));

             }

            ...
             i.putExtra("mylab",mylab);
             startActivity(i);  
         }
</code></pre>

<p>and in the linegraph activity:</p>

<pre><code>...
private double [] mylab =new double [100];

public double []  getmylab(){ return this.mylab;} 
public void setmylab(double [] mylab){ this.mylab=mylab;} 

...
public void onCreate(Bundle savedInstanceState){

Bundle extras=getIntent().getExtras();

double [] mylab=extras.getDoubleArray("mylab");
setmylab(mylab);
..
public Intent getIntent(Context context){

double []mylab=getmylab();

ArrayList&lt;Double&gt; x =new ArrayList&lt;Double&gt;();
ArrayList&lt;Double&gt; y =new ArrayList&lt;Double&gt;();


        //fill x,y values
         for (int i=0;i&lt;=20;i++){ 
             x.add(mytime/i);
         } 

       for (int i=0;i&lt;=20;i++){ 
         y.add(mylab[i]);

       } 
    ...
</code></pre>

<p>I suppose the error lies where i fill the array?</p>

<p>-------------Logcat------------------------------</p>

<blockquote>
  <p>FATAL EXCEPTION: main E/AndroidRuntime(461):</p>
  
  <p>java.lang.RuntimeException: Unable to start activity ComponentInfo</p>
  
  <p>java.lang.NullPointerException  E/AndroidRuntime(461): at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.app.ActivityThread.access$2300(ActivityThread.java:125)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.os.Handler.dispatchMessage(Handler.java:99)</p>
  
  <p>E/AndroidRuntime(461):    at android.os.Looper.loop(Looper.java:123)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.app.ActivityThread.main(ActivityThread.java:4627)</p>
  
  <p>E/AndroidRuntime(461):    at
  java.lang.reflect.Method.invokeNative(Native Method)</p>
  
  <p>E/AndroidRuntime(461):    at
  java.lang.reflect.Method.invoke(Method.java:521)</p>
  
  <p>E/AndroidRuntime(461):    at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)</p>
  
  <p>E/AndroidRuntime(461):    at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)</p>
  
  <p>E/AndroidRuntime(461):    at dalvik.system.NativeStart.main(Native
  Method) E/AndroidRuntime(461): Caused by:</p>
  
  <p>java.lang.NullPointerException E/AndroidRuntime(461):     at
  com...LineGraph.getIntent(LineGraph.java:109)  E/AndroidRuntime(461):</p>
  
  <p>at com..LineGraph.onCreate(LineGraph.java:80) E/AndroidRuntime(461):</p>
  
  <p>at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)</p>
  
  <p>E/AndroidRuntime(461):    at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)</p>
</blockquote>
