+ 1

What is the problem with the code?? Also explain how ro use "Var" keyword.

https://code.sololearn.com/cRIAZ3PJHA8K/?ref=app

24th Oct 2018, 5:43 AM
Ananya Pandey
Ananya Pandey - avatar
6 odpowiedzi
+ 6
Java 10 + is needed to use "var" keyword.
24th Oct 2018, 5:53 AM
Googel
Googel - avatar
+ 4
Ananya Pandey you didn't mention variable type.
24th Oct 2018, 9:59 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 4
in the code the Var needs to be var
25th Oct 2018, 1:29 AM
Potato Hacker
Potato Hacker - avatar
+ 2
Sololearn already said that "Var " keyword is now supported in Sololearn java playground. So my code should compile!!
24th Oct 2018, 6:20 AM
Ananya Pandey
Ananya Pandey - avatar
+ 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
24th Oct 2018, 7:03 AM
Ipang
+ 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);
24th Oct 2018, 10:02 AM
D_Stark
D_Stark - avatar