Local and Global variables (Java)

Posted: edited May 19 at 11:59 - Source : stackoverflow

I have the class X and a variable called x In my inner class Y I have a variable called y

I want: x = y

I made a Getter Method for Y and for X but the error accurs: non-static method 'getY()' cannot be referenced from a static context.

I haven't set the getX() static nor final. I have tried it both ways as well but it's not working.


public class X {
    Variable v = new Variable();
    [... here is something done with v]

    class Y {
      Variable v_new = v;
      [works with v]


    v = v_new; // ???