Question:
If I have:
class point { double x,y; } & import point; class test { public static void main(String args[]) { point[] P = new point[10]; P[0].x = 5; P[0].y = 34874; } } it generates a null pointer exception. Why?
Answer:
Try:
Your array declaration allocates an array large enough to holdonly 10 pointers to points. Space to hold each point must be allocatedseparately.P[0] = new Point(); P[0].x = 5; etc.
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.






















