. Advertisement .
..3..
. Advertisement .
..4..
I get the error: exception in thread “main” java.lang.error: unresolved compilation problem: when I try to run the program below:
class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Message messageObject = new Message ();
Time timeObject = new Time ();
System.out.println("Enter your message here: ");
String message = input.nextLine();
messageObject.simpleMessage(message);
timeObject.getTime();
}
void simpleMessage(String message) {
System.out.println(message + time);
}
}
The error appears the system notifies as follows:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Message cannot be resolved to a type
Message cannot be resolved to a type
The constructor Time() is undefined
at Test.main(Test.java:8)
I tried to solve it with another sample. I got the reference in the community forum, but it still returned an invalid result. If someone knows the solution, please give me the support. Thanks!
The cause: The problem lies in the following line:
Message messageObject = new Message ();
Solution: This error indicates that the
Message
class was not available at compile time. You will need to import the message class.This is how it looks:
There are two options. Java Version incompatible, import