So I tried to get back to Java after 2 years, having forgotten alomost everything I had learnt, so I wanted to start with something basic but I’ve ran into an error next to the ‘public static void main ()’ line, saying missing method body, I just typed a basic code to check if an enetered number is even or not, so could someone tell me what I am doing wrong. Please? If it helps I use the BlueJ IDE.
import java.util.*;
class Test {
public static void main ();{
Scanner sc=new Scanner(System.in);
System.out.println("Enter number : ");
int n=sc.nextInt();
if (n%2==0)
System.out.println("Even number");
else
System.out.println("Odd number");}
}
enter image description here
I tried couple of times to change things and the problem still persists. I have gone over the code many times but still can’t figure out what the problem is.
Pranjal Shukla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.