0

Why I am getting error in java?

I am just beginners to java.And started getting errors in variables. https://code.sololearn.com/cT48VgQWF9CB/?ref=app

11th Mar 2021, 4:41 PM
Vinay Jaiswal
Vinay Jaiswal - avatar
6 Answers
+ 4
Vinay Jaiswal Because vi is a character and you have initialised as a string. Single quotes represent character Double quotes represent String
11th Mar 2021, 5:10 PM
A͢J
A͢J - avatar
+ 2
try char vi='D';
11th Mar 2021, 4:43 PM
Igor Kostrikin
Igor Kostrikin - avatar
+ 1
Thanks
11th Mar 2021, 5:16 PM
Vinay Jaiswal
Vinay Jaiswal - avatar
0
Igor Kostrikin,your variable is working.But why not my one.
11th Mar 2021, 5:07 PM
Vinay Jaiswal
Vinay Jaiswal - avatar
0
Oooooo
11th Mar 2021, 5:16 PM
Vinay Jaiswal
Vinay Jaiswal - avatar
0
Vinay Jaiswal thats because its 2 different types. Python and js ignore that. Nvm if u use " " or ' '. But C family and Java (as i know C is parent for Java?🤔🤔) are strict for this. So, " " not equals to ' '. Double quotes " " - are for strings, single quotes ' ' - are for chars
11th Mar 2021, 10:37 PM
Nazeekk
Nazeekk - avatar