开发者

2d String Array NullPointerException (java)

I am currently creating a java application in which I have a 2d array which I want to get some data into.

开发者_如何学编程I am creating the 2d array as such

String[][] addressData;

and then when I am trying to put data in I am using reference the exact position in the 2d array I want to enter the data into e.g

addressData[0][0] = "String Data";

The program compiles yet when I run I get a NullPointerException error. Am I using the wrong method to enter data into this 2d array?


String[][] addressData - this is just declaration, you have to create actual object String[][] addressData = new String[size][size];

Btw, There is no 2d arrays in java String[][] is an array of arrays of strings

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜