i have an array of strings which i want to convert to int, pretty simple and straightforward here is the code :

```
public static void main(String[] args) {
    String myarray[]=readfile("[pathtothefile]");

     int mynums[] = new int[myarray.length];
    for (int i=0;i<myarray.length;i++){
        mynums[i]=Integer.parseInt(myarray[i]);
    }
    System.out.print(Arrays.toString(mynums));  
}

```

But the Problem here is, if i initialize "mynums" like this: **mynums[]=null;** i get **NullPointerException** on the following line:

```
"mynums[i]=Integer.parseInt(myarray[i]);" 

```

what i have to do to solve it is 

```
int mynums[] = new int[myarray.length]; 

```

[here](https://stackoverflow.com/questions/8089798/strange-java-string-array-null-pointer-exception?rq=1) someone explained why it happens but i dont know how to initialize now! i mean sometimes i dont know how big my array can get and i just want to initialize it. is it even possible?