Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a static method from main()

 
Banah Vor
Greenhorn
Posts: 1
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to call a method from the main() but encountered NullPointerException once it tries to call. The code is something like this.



I'm fairly new in java and your assistance will be valued.

 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please PostRealCode and also the stacktrace so that we can get to know what the code is trying to do.
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Sanaulla wrote:Please PostRealCode and also the stacktrace so that we can get to know what the code is trying to do.


yup...
The snippet you've posted doesn't show anything as to what is null there...
Need the actual code here
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

NullPointerExceptions are most of the time easy to track down and fix. Look at the stack trace that you get from the exception. It tells you exactly in which source file, and which line of code, the exception happens. Go to that spot in your source code and find out what could be null there that is not supposed to be null.

The most common causes of a NullPointerException are trying to call a method on a variable that is null or trying to access a member variable while the variable that refers to the object is null.

The outline of your code that you posted doesn't give enough information to help you with this problem.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

As you have already been told, it is impossible to help with your problem unless we know more details.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic