Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why am I getting a NullPointerException in this example

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vishnu prakash:
Why am I getting a NullPointerException in this example...

Because you set av to null, then tried to call an instance method without an instance...

If you need to call video() without having a specific instance of AudioVideo, then video() should be static.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explanation.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic