Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » im getting "var cannot be resolved to a type" error(var error eclipse)
im getting "var cannot be resolved to a type" error [message #1826508] Sun, 26 April 2020 02:46 Go to next message
Eclipse UserFriend
hey guys! i just started java and my first problem occured, but i guess there is something to be fixed in compiler. im getting a var error. for some reason the compiler cannot recognize var

ive been googling and ive noticed that it is a common "issue"

any one here who can help me out? im using eclipse 4.15.0

thanks

public class VarDemo2 {

ppublic class VarDemo2 {
public static void main(String args[]) {
var mc = new MyClass(10);
System.out.println("Value of i in mc is " +
mc.geti());
mc.seti(19);
System.out.println("Value of i in mc is now "
+ mc.get());
}
}
}

Error: Exception in thread "main" java.lang.Error: Unresolved compilation problem:

var cannot be resolved to a type
at VarDemo2.main([VarDemo2.java:4]

[Updated on: Mon, 15 February 2021 09:52] by Moderator

Re: im getting "var cannot be resolved to a type" error [message #1826535 is a reply to message #1826508] Sun, 26 April 2020 14:07 Go to previous message
Eclipse UserFriend
Some observations:

Your code has a few extra errors: duplicate class header, typo in "ppublic".

The message that you are seeing when you try to run the program should be immediately visible as compile errors (in the editor and also in the Problems view). If you see such compile errors, you should fix them, before trying to run the program :)

Whether or not the compile error is raised, depends on your Java compliance settings. 'var' was introduced in Java 10, so when you configure your project for Java 8, e.g., then 'var' is indeed not legal instead of a type.
Previous Topic:Character.isIdentifierIgnorable
Next Topic:Breakpoint in debugged application doesn't show source file, after upgrade to 2020-03
Goto Forum:
  


Current Time: Sun Jul 06 11:24:45 EDT 2025

Powered by FUDForum. Page generated in 0.05629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top