private variables in java?
===

i was watching a tutorial on youtube and the topic was private variables. we usually set variables in java like this:

    class hello{
    public static void main(String args[]){
    String x;
    x = "Hello"
    }
    }
but in that tutorial, the string type was declared out of the method like this:

    class hello{
    String x;
    public void apples(){
    x = "this is a private variable."
    System.out.println(x);
    }
    }

as you can see it was not the main method. but i want to ask that do private variables always have to be out of method or what?

i am a beginner so this will be really helpful to know as i don't want to cram up knowledge to prevent confusion and also because it is a matter of fact that people who cram up code never become a good programmer.