Non-static variables used in a non-static method but doesn't work

Hi everyone. I have two classes in two .java files (DateDriver) and (DateAD)

Here are the variables declared in the DateAD class :

publicshort dayOfWeek = 0;

publicshort dayOfMonth = 0;

publicshort dayOfYear = 0;

publicshort month;

publicshort year;

And here is what I am trying to do with them from the DateDriver class

publicclass DateDriver

{

publicvoid main(String[] args)

{

DateAD aDay =new DateAD();

System.out.println("The Date Is : " + DateAD.dayOfWeek +", " + DateAD.dayOfMonth +" " + DateAD.month +", " + DateAD.year);

}

I am getting an error "non-static variable __ cannot be referenced from a static context" for all 4 of the variables I'm using in the println's argument. Any ideas on how I can fix these?

Thanks!

Message was edited by:

ApRiX

[1558 byte] By [ApRiXa] at [2007-11-27 4:58:28]
# 1
you missed "static" in your "public static void main" definitionplus: you should do aDay.field and not DateAD.field in the println
calvino_inda at 2007-7-12 10:14:21 > top of Java-index,Java Essentials,Java Programming...
# 2

The "static context" in the error message doesn't refer to the method in which you reference the variables. It's talking about the fact that you're accessing them through the class DateAD instead of through an instance of the class. By removing the static keyword from the main() method declaration, all you did was make it impossible to run your program.

uncle_alicea at 2007-7-12 10:14:21 > top of Java-index,Java Essentials,Java Programming...