need help with Static and non-static methods and feilds

Discussion in 'Java' started by o_ssie, Apr 9, 2009.

  1. o_ssie

    o_ssie

    Joined:
    Apr 9, 2009
    Messages:
    1
    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
    o_ssie, Apr 9, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oliver Wong
    Replies:
    14
    Views:
    1,585
    Chris Uppal
    Jun 13, 2006
  2. pintu

    Static V/s Non Static Methods

    pintu, Jun 27, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    522
    active
    Jun 28, 2007
  3. m97rek
    Replies:
    3
    Views:
    1,004
    Are Nybakk
    Nov 3, 2007
  4. Dobedani
    Replies:
    0
    Views:
    369
    Dobedani
    Jul 15, 2008
  5. rickman
    Replies:
    5
    Views:
    414
    rickman
    Mar 30, 2013
Loading...

Share This Page