|
-
Sep 27th, 2007, 01:08 AM
#1
Thread Starter
Lively Member
[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
-
Sep 27th, 2007, 08:40 AM
#2
Re: an array index reference..
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 27th, 2007, 08:42 AM
#3
Thread Starter
Lively Member
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)
-
Sep 27th, 2007, 09:04 AM
#4
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);
}
}
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 27th, 2007, 09:14 AM
#5
Thread Starter
Lively Member
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;
-
Sep 27th, 2007, 12:15 PM
#6
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|