I am using a Calendar to gain access to the current year.
This is my code…
import java.util.Calendar;
Calendar c = c.getInstance();
int year = c.get(c.YEAR);
The code compiles and runs fine, but it displays a warning message saying “Warning, accessing a static field” Is there something wrong, or should I be doing something better?
Use
Calendar.getInstance()andCalendar.YEAR, static fields should not be accessed using instance objects.