• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instantiating class in a static method

 
akash gall
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am supporting this project. Now I am getting this error, Cannot make a static reference to the non-static method myMethod() from the type XMLParser2

From the static method, I am trying to call my method in another class (which is not static)

Is there any way this can be done, as I cant change the original method.

Thanks.


 
Campbell Ritchie
Sheriff
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
That is a common mistake. You are trying to contact something from a static method, possibly the main method. You should consider whether you are right working in a static context in the first place. Then, you need to create an object reference and call methods on that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic