|
-
December 7th, 2011, 09:00 AM
#1
java.lang.NullPointerException
hi, I am creating a class and trying to create an array of that class, then giving value to the variables contained in the class but get the infamous NullPointerException. How can I give a value to the values of the variables in the class (in this case x and y)?
Thanks
This is my code:
class Point {
int x, y;
}
class Test {
public static void main(String[] args) {
Point[] pa = new Point[10];
pa[1].x=1;
}
}
This is the output:
Exception in thread "main" java.lang.NullPointerException
at Test.main(test.java:8)
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
|