import java.util.List;
public class Main {
public static void main(String[] args) {
var listOfColors = List.of("Red", "Blue", "Yellow"); // <- Here
var dummyClass = new DummyClass(); // <- And here
dummyClass.printColors(listOfColors);
}
}
class DummyClass {
void printColors(List<String> colors) {
for (String color : colors) {
System.out.println(color);
}
}
}
#Why can't I use `var` anymore?
1 messages · Page 1 of 1 (latest)
Detected code, here are some useful tools:
<@&987246399047479336> please have a look, thanks.
Yeah, sorry, uploading those images took some time
That's what I mean though
So it says:
as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
Like, wat?
And I set my application to release 25 right
try selecting "clean cache" or sth like that it was called. in the top left corner of intellij in the dropdown and restart intellij
Is this the correct popup you're referring to?
Are there any checkboxes you want me to check or no?
Also, should I click on "Just restart" or "Invalidate and Restart"?
check all and invalidate/restart
Same thing occurs actually..
I mean, I can maybe change the language level down to something which works, but don't get what's wrong with 25
25 is where I get the latest features right?
That's what language level means?
Okay, I thought that post would work, but it still didn't..
Which version do you have set in your pom?
u can also send us the Main.class file that u will find in that target folder
it will tell us in which java version it was compiled
that might help as well
but yeah, if its still using the wrong version its probably in the pom.xml file
click on modules and check what language level is set there
just do ctrl alt shift s for intellije on windows, opens up the project structure, you can view the project structure and the language level
along with the jdk version
Oh shit, I forgot to update this thread
bro u mean when u used jdk 25
compile error of var not anymore used within jdk25 ?
because im using jdk21 i have no idea about 25 !
I meant to say, the issue is now resolved, the problem was that my pom.xml file said to compile the project against JDK version 9 (instead of 25)
25 is out and is LTS, yes