/*
 * TimeErrors.java is used to show some issues with reference variables
*/

public class TimeErrors {
      Time someTime;
    public static void main(String[] args)
    {
        //Time myTime;
        //System.out.println(myTime);
/*
TimeErrors.java:10: variable myTime might not have been initialized
                System.out.println(myTime);
                                   ^
*/

        //System.out.println(someTime);
/* Compiler generated message:
TimeErrors.java:11: non-static variable someTime cannot be referenced from a static context
                System.out.println(someTime);
                                   ^
*/


        // doSomething();
/* Compiler generated message:
TimeErrors.java:23: non-static method doSomething() cannot be referenced from a
static context
                doSomething();
                ^
*/
        TimeErrors error = new TimeErrors();
        error.doSomething();
    }

    public void doSomething()
    {
        System.out.println(someTime); // prints null
        System.out.println(someTime.getHour());
    }
}

/* Result of execution
Exception in thread "main" java.lang.NullPointerException
        at TimeErrors.doSomething(TimeErrors.java:30)
        at TimeErrors.main(TimeErrors.java:24)
*/