Basics Flashcards
They perform operations on numbers, strings, and other values
literals
(5) basic literals
integers, characters, strings, boolean, and arrays
numbers
integer or int
A single character can represent a digit, a letter, or another symbol
character or char
To write a single character, we wrap in
single quotes
NOTE: Character literals can represent alphabet letters, digits from ‘0’ to ‘9’, whitespaces (‘ ‘), or some other symbols
incorrect: ‘abc’, ‘543’
text information
string
To write strings, we wrap characters in
double quotes
NOTE: “text”, “I want to learn Kotlin”, “123456”, “e-mail@gmail.com”
A string can also contain just one single character, like “A”. Do not confuse it with the character ‘A’, which is not a string.
(6) relational operators
== — equal to X
!= — not equal to X
> — greater than X
> = — greater than or equal to X
< — less than X
<= — less than or equal to X
NOTE: Boolean value (true or false)
a way of writing numbers using only two digits, 0 and 1
binary numeral system or base-2 numeral system
when a digit reaches 1, the next number resets this digit to 0 and causes the digit to the left to raise
binary counting
work with binary numbers of a fixed length
zero padding
NOTE:
- triads: 000, 001, 010, and so on;
- tetrads: 0110, 0111, and so on;
- 8-digit numbers: 00000000, 01010101, and so on.
An 8-digit binary number
NOTE: 256 possible values from 0 to 255
byte
a way of storing information
binary code
each character in the text string represented by a 7-digit binary number
ASCII code
(American Standard Code for Information Interchange)
Red, Green, Blue
NOTE: color encoding system stores 3 binary values
RGB
a standard for encoding and representing text
Unicode
every symbol corresponds to a number
code point
Unicode is represented with
U+
NOTE: Capital Letter Q is U+0051
(6) escape or control sequences
‘\n’ is the newline character;
‘\t’ is the tab character;
‘\r’ is the carriage return character;
’\’ is the backslash character itself;
’'’ is the single quote mark;
’"’ is the double quote mark.
isDigit()
returns true if the given character represents a digit (‘1’, ‘2’, etc); otherwise, false
isLetter()
returns true if the given character represents a letter (‘a’, ‘B’, ‘m’, etc); otherwise, false
isLetterOrDigit()
returns true if the given character represents a letter or a digit; otherwise, false
isWhitespace()
returns true if the given character represents a whitespace (‘ ‘, or ‘\t’, or ‘\n’); otherwise, false
isUpperCase()
returns true if the given character is an uppercase character; otherwise, false
isLowerCase()
returns true if the given character is a lowercase character; otherwise, false
uppercaseChar()
returns the uppercase form of the given character
uppercase()
returns a String with the uppercase form of the given character
lowercaseChar()
returns the lowercase form of the given character
lowercase()
returns a String with the lowercase form of the given character