Suppose c is variable of type char. How would you test whether the value of c is single quote character? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Suppose c is variable of type char. How would you test whether the value of c is single quote character?

23rd Aug 2017, 11:14 AM
Parvej Chauhan
Parvej Chauhan - avatar
2 ответов
+ 3
c == '\'' // Note that '' is 2 single quotes: ' Similar thing for double quotes in Strings: String a = "\"a"; The value of a is: "a
23rd Aug 2017, 5:19 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
char c = '\''; return c == '\''; is one way to check if the value of c is the '. or in the jshell, you can do: char c = '\'' c == '\'' // output $456 ==> true
23rd Aug 2017, 12:03 PM
Venkatesh Pitta
Venkatesh Pitta - avatar