Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Char Type | Core Data Types
Kotlin Data Types

bookChar Type

Deslize para mostrar o menu

The Char type in Kotlin is used to represent a single character. You declare a Char variable using single quotes around the character, such as 'A' or '1'. Unlike String, which can hold multiple characters, a Char always holds exactly one character. Valid Char values include letters, digits, symbols, or special escape characters.

Main.kt

Main.kt

copy

Escape characters allow you to represent special characters in a Char value using a backslash (\). For instance, \n represents a newline character, and \t represents a tab. In the code above, val newLine: Char = '\n' assigns the newline character to a variable, and val tabChar: Char = '\t' assigns the tab character. When you print these characters, they control formatting in the console output rather than displaying as visible symbols.

question mark

Which of the following is a valid Char declaration in Kotlin?

Selecione todas as respostas corretas

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 3

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 1. Capítulo 3
some-alt