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
NullPointerExceptionbecause you didn’t initialize the array(). You have to do something like this:to initialize an array with 50 elements.