Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:46 Go to next message
Fort vin is currently offline Fort vinFriend
Messages: 2
Registered: April 2020
Junior Member
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 14:52] by Moderator

Report message to a moderator

Re: im getting "var cannot be resolved to a type" error [message #1826535 is a reply to message #1826508] Sun, 26 April 2020 18:07 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
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: Thu Dec 05 02:02:00 GMT 2024

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

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

Back to the top