+ 1

Invalid character constant

Hello, I have a Code in that there is a variable called loesung. I want so set this variable to ".-". But it doesnt work. Can somebody help me? Thank you! char loesung = '.-';

11th Aug 2019, 9:21 AM
Peter Möhle
Peter Möhle - avatar
4 ответов
+ 12
Becz char type veriable does not contain two characters. Use String String loesung = ".-";
11th Aug 2019, 9:26 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 13
Keep in mind that whenever you use the A string variable, keep any character inside the double quto like this ("hello")
11th Aug 2019, 9:32 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 3
With String i have the same Error.
11th Aug 2019, 9:28 AM
Peter Möhle
Peter Möhle - avatar
+ 3
use String or try a char array : char []c={'.','-'}; System.out.print(c[0]+""+c[1]);
11th Aug 2019, 12:14 PM
Mouadh Ben Abdallah
Mouadh Ben Abdallah - avatar