?
Solved

null pointer exception

Posted on 2004-11-11
2
Medium Priority
?
196 Views
Last Modified: 2010-03-31
I'm not sure what i'm doing wrong i create a class in point.java called point that looks like:
public final class point
{
      private int x;
      private int y;
}

Then in another class called Distance.java i have my main method that looks like:
public class Distance
{
      public static void main(String[] args)
      {
            int size = 2048;
            point[] Parray = new point[size];
            Parray[0].x=4;
               }
}
at the line Parray[0].x=4; i keep getting the following error:
Exception in thread "main" java.lang.NullPointerException
I'm not sure what i'm doing wrong
0
Comment
Question by:vonster
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
petmagdy earned 150 total points
ID: 12556538
Parray[0] = new point();
          Parray[0].x=4;
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12556545
also u need a constractor to ur point class
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month16 days, 6 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question