Stuck in a weird problem...
Hi everyone. I'm a beginner to Java so my question may seem foolish and I apologize in advance! First of all, I have two .java files in a package (DateDriver.java and DateAD.java). I won't be able to explain this well in words so I'll just start off by pasting some code.
Here is my main method in DateDriver.java
publicvoid main(String[] args)
{
if (args.length == 0)
{
DateAD.DateAD();
}
Here is my DateAD method in DateAD.java
publicstaticvoid DateAD()
{
setCurrentDate();
}
And the method setCurrentDate that is also in DateAD.java
publicvoid setCurrentDate()
{
GregorianCalendar cal =new GregorianCalendar();
month = (short)cal.get(GregorianCalendar.MONTH);
year = (short)cal.get(GregorianCalendar.YEAR);
dayOfMonth = (short)cal.get(GregorianCalendar.DAY_OF_MONTH);
}
Alright! My main function in DateDriver.java can successfully invoke the method in DateAD.java however I am getting an error "non-static method setCurrentDate() cannot be referenced from a static context". I tried changing the methods from static to non-static and so forth but anyway I do it I always get an error similar to that one.
Is there a way I can get my main method in DateDriver.java to successfully invoke the DateAD method in DateAD.java and at the same time have the DateAD method successfully invoke setCurrentDate()?
Thanks!

