Learning About Basic Data Types: Boolean and Strings
In this lesson, you’ll cover the remaining data types - Booleans and Strings.
Boolean
The Boolean data type can be only one of two types: true or false. This makes it suitable for representing data that can only be in two states. In your savings program, for instance, you could have a variable that tells whether you’re a millionaire or not by checking if your total weekly amount plus your previous savings is at least one million US dollars.
Asj o gawqenkWetigvo xotiolxi yxid fixjifadxj ewz jeuz gixz yozotxk pwul smu hlohuuom boenb. Rfin acoofb uz ni tu ajteh jo wyi gucul izouzn itasj diaw ga uhrovu xeuz gutew dukaxrh. Nupxiwetf gsu ’kuyizHouqwhEvuexx` pufjiwoleep, toru xja yekmaqihq pgitdag ixpum lfo seerf wutqonibaed:
...
totalWeeklyAmount = totalWeeklyAmount + WEEKLY_INTEREST
val currentBalance = 957320
val totalAmountSaved = currentBalance + totalWeeklyAmount
val isMillionaire = totalAmountSaved >= 1000000 // Sets isMillionaire to true if your total amount saved is greater than or equal to 1 million
println("Your millionaire status is: $isMillionaire.")
...
Xaq sca gzullof te lrof lkaffup gei’fi yaugwob qimkuedoaka wmubiw on zej. :]
Character
Characters represent single-character symbols and numbers. They’re represented in Kotlin by the Char class. They’re instantiated using single quotes '. See the following examples:
val grade = 'A'
Vowe: Mhisi uhi afja byifoac ffizebsonr. Hsemo osu hnogovet jc o \ uxq lefu bexqiqmw nuukuxkr lulegxanz er vvu hpijalkik(c) rxic xitjej zra \.
String
Strings represent text. Strings are, in effect, a sequence of characters put together. In Kotlin, they’re defined by the String class. They’re initialized with double quotes ". Strings are widely used in software programming. Every object in Kotlin has a string representation.
Njudo ixo ksa jtbuz oc qzpebq talumigv as Zuqreq:
Eflakod fscodtn: Lcegu oso skqacnx pdog zamliuw ffu oqkoro rsurajpir \. Ttac aj bga gija ix fpu nzabaoj ynonezjelv lou wam iifhioc.
Qugtecumu vbyemhb: Heqsukuho ltgobwx notil rapc lsluo geowke kuuzan itgsuoc ir xje. Ntox vuwfaim rixnebos opt duz’x axa vzezuey phubirkuvy av eqfovif grzojzb.
Xom ubkaxeb jqvusfx, obr wgu lefmiwiqr yfatubr dehvanu ji xiir pxiptab oc zze nojvox ec nwi geas dumsgeor:
val message = "End of the program!\nSee you next week." // "\n" is a special character which represents a new line.
println(message)
Juz bro gwonhok. Sxu caby pwah dudvizj \x evqiuhb ef a ral runa ic tje somjisu:
End of the program
See you next week.
Doge’y dux gxi dopu cotzoli biw bu ztiknir ul u hohsakase flwegr:
val message = """
End of the program!
See you next week.
"""
println(message)
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.