Reputation: 1
I'm beginning to learn Java. While following a YouTube tutorial, I entered the following code:
import java.util.Scanner;
public class ageclass {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int age;
System.out.println("How older are you?");
age=in.nextInt();
if (age >= 18)
System.out.println("you are old enough to drink");
else
System.out.println("you are not old enough");
}
}
The code threw this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at age.ageclass.main(ageclass.java:6)
I have looked at another thread that had an answer but I couldn't understand it. Could someone explain to me what has gone wrong?
Upvotes: 0
Views: 583
Reputation: 45
if you are using eclipse try to clean the project.
Project -> Clean... -> select your project -> OK
Upvotes: 2