non-static method isEven(int) cannot be referenced from a static context
843785Jan 29 2009 — edited Jan 29 2009That is the error message that I am getting. I am not sure what to do to get it run. Is there a way to make method isEven(int) static so that it can be referenced???? Thanks to all in advance!
import java.util.Scanner;
/**
*
* @author Jason
*/
public class evenOdd
{
public static void main (String[] args)
{
Scanner input = new Scanner (System.in);
{
while (input.hasNext())
{
int number = input.nextInt();
if ( isEven( number ) ) *<----------------------------------------------------- Here is the problem*
System.out.printf( "%d is even\n", number );
else
System.out.printf( "%d is odd\n", number );
}
}
}
public boolean isEven( int number )
{
return number % 2 == 0;
}
}