Java Language | Error :- non-static variable scan cannot be referenced from a static context : <pre><code>import java.util.Scanner;

class Program
{
    public static void main(String[] args)
    {
        Customer customer = new Customer();
        Customer.method();
    }
}

class Customer
{
    **Scanner scan = new Scanner(System.in);**

    public static void method()
    {             
        System.out.print("Name : "); // error  **non-static variable scan cannot be referenced from a static context**
        String name = scan.nextLine();
    }
}
</code></pre>

<p><strong>Question :-</strong> while creating an Scanner class object outside the method() there is an compilation error :- <strong>non-static variable scan cannot be referenced from a static context</strong> but when i define it inside the method() it is working without error Why ?</p>

<p><strong>Question :-</strong> How to create Scanner class Object that every class can use that single object which is defined at one place in a program. Is this possible ?</p>
