Andy Richard wrote:@Chan
This is the error i got..
Are you sure you have posted the same code here? The source code that you have posted is of 'check.java' whereas that error suggests you are trying to run some 'Check' class which would have been created if some 'Check.java' had successfully compiled.
By the way, the source code you have posted gives me the following compilation error ( I added the missing closing brace at the end of your code or that would have given me a different compilation error ).
C:\Users\myPath>javac check.java
check.java:36: cannot find symbol
symbol : method getType()
location: class check
System.out.println("Variable, stored contains.." + stored.getType());
^
1 error
Since compilation is not successful, the .class file is not formed and hence
java cannot find the class if you try to execute it.
C:\Users\myPath>java check
Error: Could not find or load main class check
If you try to run a java program in an
IDE without resolving the compilation error ( this is what we shouldn't do - cause executing a program requires the class file which is the output of a successful compilation process ), the IDE gives you the following kind of a message.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
< the description of the compilation error>
So for the source code you have posted, I would get the following error.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method getType() is undefined for the type check
at threadandsynchronization.check.main(check.java:40)