Whenever I introduce the array, i get this error. I tried different array types...but no luck.
public class Classifytestclass2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
int test2[] = null;
for(int i=0;i<50;i++){
test2[0]=1;
}
}
}
edit: forgot to mention, the entire app crashes (force close.)
It's normal to get a NullPointerException because you didn't initialize the array(). You have to do something like this:
int test2[] = new int[50];
to initialize an array with 50 elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With