Char
In this page:
Char
A Char represents a single UTF-16 character, written with single quotes, like A. Characters can be compared and cast to their underlying numeric code point with .toInt. Double quotes are reserved for String, not Char, and mixing them up is a common beginner mistake.
Note: Casting a Char to Int with .toInt gives you its Unicode code point.
Example: Char
object Main extends App {
val letter: Char = 'A'
val digit: Char = '7'
println(letter)
println(letter.toInt)
println(digit.isDigit)
}
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: