开发者

2d String Array NullPointerException (java)

开发者 https://www.devze.com 2022-12-12 02:17 出处:网络
I am currently creating a java application in which I have a 2d array which I want to get some data into.

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

精彩评论

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