Invalid character constant | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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