+ 1
What is the problem with the code?? Also explain how ro use "Var" keyword.
6 odpowiedzi
+ 6
Java 10 + is needed to use "var" keyword.
+ 4
Ananya Pandey you didn't mention variable type.
+ 4
in the code the Var needs to be var
+ 2
Sololearn already said that "Var " keyword is now supported in Sololearn java playground. So my code should compile!!
+ 2
Don't know much Java, but I think you should've used 'var' instead of 'Var', also when I changed it to 'var' Java gave another error message:
"'var' is not allowed in a compound declaration"
But it will work if a, b, c, and d are all declared on different lines.
Hth, cmiiw
+ 1
/*might not look like how you expected it too but this is the right way using var as it needs to be clear what type it is.. in my opinion i would stick to using int and String you can do shorthand declarations that way*/
var a=1;
var b=5;
int c;
String d;
c=a+b;
d=c+"";
System.out.println(d);