Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot understand the exception in my code,please help

 
liu hao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the null Point exception occurs at the at but I think my constructor has initialized the point2D objects.
please point out my mistake. tons of thanks.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
liu hao wrote:the null Point exception occurs at the at


in which line you invoking this ? instead please tell the line number
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are never initialising the Point2D objects in your MyRectangle class. In your constructor (or in the declaration) you need to create new objects for these. For example, your method setBottomLeftPoint attempts to do something like null.setLocation(...).

OR, simply assign the Point2D objects that you are passing to your constructor to your instance variables.
 
liu hao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a lot of thanks.It seems I didn't understand that staff thoroughly.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic