You will need to create an instance of your class to call this method from the main method if you want to make your method non-static. And then you can make your isLeapYear variable non-static: -
boolean isLeapYear; public static void main(String[] args) { int year = 2000; new Assigment().isLeapYear(year); } public boolean isLeapYear(int year) {
But, for sure, you do not need to save your result in a boolean variable. If you want to return the boolean value of some expression, you can simply return this expression.
So, just the presence of this code in your method will also work fine, and it is more readable, and let this method be static: -
return (((year/100)%4 == 0 && year%4 ==0) || (year % 400 == 0))
And from your main call: -
System.out.println("Year : " + year + ", is leap year: " + isLeapYear(year));
source share