[RESOLVED] an array index reference..
hi all,
i'm jst struggling with a fundermental problem with the addressing method of a 2-D array. it's very simple problem but i've jst been unable to find the solution ..
the problem is...
im having a 2-D array of integer..
int[][] myArray = new int[5][10];
and i need to refer one whole row at once... say to refer the 2nd whole row...
how could i do it?
it's giving an error when i use " myArray[1] " to refer the 2nd row.
could you pls help me to solve this problem...
thanking in advance.
bye
Re: an array index reference..
Re: an array index reference..
Exception in thread "main" java.lang.NullPointerException
at com.xpl.Client.loadUserStories(Client.java:152)
at com.xpl.Client.main(Client.java:43)
Re: an array index reference..
I don't know what's throwing that exception, you should show us some code if you need more help
The null pointer exception is thrown when an application uses a null value where an object is expected.
Here is also a code sample on using a 2D array
Code:
public static void main(String[] args) throws ClassNotFoundException {
int[][] myArray = new int[5][10];
print(myArray[1]);
}
public static void print(int[] array)
{
for(int i:array){
System.out.println(i);
}
}
Re: an array index reference..
ComputerJy,
thanks for ur help. i jst got the error, an object was accessed before initializing.. now it woking porperly..ya i got ur point.. have to give some more details when asking something..
thanks for advices;
Re: an array index reference..
you're welcome
If you are done here, please don't forget to mark the thread resolved from the "Thread Tools" menu