Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > need help with Static and non-static methods and feilds

Reply
Thread Tools

need help with Static and non-static methods and feilds

 
 
o_ssie o_ssie is offline
Junior Member
Join Date: Apr 2009
Posts: 1
 
      04-09-2009
Hello, I was hoping someone could help.

I have a variable in a class that I would like to call in another class in the same package. However when I try calling it I get an "non-static variabe cannot be referenced from a static context". Now my bandaid solution was to just make the variable static and move on with my life. Unfortunatly I'm not allowed to do that. is there any other way for these classes to talk to each other with the variables being static?

I'm also running into the same issue with calling methods from a different class. it gives me the same error saying that method has to be static.

I can post the code if it'll help to understand what im saying

any input would help.. thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static methods verus Instance methods lightning Java 4 10-30-2008 04:40 AM
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
Avoid calling non-final methods in a constructor: Applies to static methods too? Oliver Wong Java 14 06-13-2006 09:18 AM
Why Petshop Changed all static methods to instance methods when upgrading from version 3.0 to version 3.1? Neo ASP .Net 1 01-07-2005 01:46 AM
Instantiating a static class( Class with all static members - methods and variables) SaravanaKumar Java 6 10-19-2004 08:20 AM



Advertisments