{"id":3177,"date":"2025-11-25T16:07:41","date_gmt":"2025-11-25T15:07:41","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=3177"},"modified":"2025-11-25T16:07:43","modified_gmt":"2025-11-25T15:07:43","slug":"kotlin-variables-and-data-types","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/","title":{"rendered":"Kotlin Variables and Data Types"},"content":{"rendered":"\n<p>Kotlin is a modern, concise, and type-safe <a href=\"https:\/\/codeflarelimited.com\">programming language used for Android development<\/a>, backend systems, desktop apps, and more. One of the core foundations of Kotlin is how it handles\u00a0<strong>variables<\/strong>\u00a0and\u00a0<strong>data types<\/strong>. Understanding these is essential because they define how your program stores and manipulates information.<\/p>\n\n\n\n<p>This post covers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What variables are<\/li>\n\n\n\n<li>Mutable vs immutable variables<\/li>\n\n\n\n<li>Type inference<\/li>\n\n\n\n<li>Kotlin\u2019s built-in data types<\/li>\n\n\n\n<li>Strings, arrays, collections<\/li>\n\n\n\n<li>Null safety<\/li>\n\n\n\n<li>Examples for each concept<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/app.codeflarelimited.com\">Start learning Kotlin online<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. What is a Variable in Kotlin?<\/strong><\/h2>\n\n\n\n<p>A&nbsp;<strong>variable<\/strong>&nbsp;is a container that stores data in memory.<\/p>\n\n\n\n<p>In Kotlin, you define a variable using two keywords:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>val<\/code>\u00a0\u2192 immutable (cannot be changed)<\/li>\n\n\n\n<li><code>var<\/code>\u00a0\u2192 mutable (can be changed)<\/li>\n<\/ul>\n\n\n\n<p>Kotlin encourages immutability because it makes your code safer and more predictable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Immutable Variables (<code>val<\/code>)<\/strong><\/h2>\n\n\n\n<p>Use&nbsp;<code>val<\/code>&nbsp;when the value should&nbsp;<strong>not change<\/strong>&nbsp;after being assigned.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val name = \"Luke\"\nval age = 30<\/code><\/pre>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>name<\/code>\u00a0and\u00a0<code>age<\/code>\u00a0cannot be reassigned.<\/li>\n\n\n\n<li>Trying to change them will produce a compilation error.<\/li>\n<\/ul>\n\n\n\n<p>Immutability is best practice for most variables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Mutable Variables (<code>var<\/code>)<\/strong><\/h2>\n\n\n\n<p>Use&nbsp;<code>var<\/code>&nbsp;when the value&nbsp;<strong>needs to change<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">var score = 10\nscore = 20   \/\/ \u2714 allowed<\/code><\/pre>\n\n\n\n<p>Use&nbsp;<code>var<\/code>&nbsp;for variables like counters, states, and temporary values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Type Inference in Kotlin<\/strong><\/h2>\n\n\n\n<p>Kotlin is a statically typed language, meaning variable types are known at compile time.<br>However, you do not always need to specify the type because Kotlin can infer it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val city = \"Lagos\"    \/\/ inferred as String\nval temperature = 28  \/\/ inferred as Int<\/code><\/pre>\n\n\n\n<p>If you want, you can explicitly set the type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val city: String = \"Lagos\"\nval temperature: Int = 28<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Kotlin Basic Data Types<\/strong><\/h2>\n\n\n\n<p>Kotlin includes several built-in&nbsp;<strong>primitive data types<\/strong>, but unlike Java, they are all objects under the hood (no primitive vs wrapper distinction).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Numerical Types<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Integer Types<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Type<\/th><th>Range<\/th><\/tr><\/thead><tbody><tr><td><code>Byte<\/code><\/td><td>-128 to 127<\/td><\/tr><tr><td><code>Short<\/code><\/td><td>-32,768 to 32,767<\/td><\/tr><tr><td><code>Int<\/code><\/td><td>-2^31 to 2^31-1<\/td><\/tr><tr><td><code>Long<\/code><\/td><td>-2^63 to 2^63-1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val count: Int = 100\nval population: Long = 7_800_000_000<\/code><\/pre>\n\n\n\n<p>The underscore&nbsp;<code>_<\/code>&nbsp;improves readability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Floating-Point Types<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Type<\/th><th>Precision<\/th><\/tr><\/thead><tbody><tr><td><code>Float<\/code><\/td><td>6-7 decimal digits<\/td><\/tr><tr><td><code>Double<\/code><\/td><td>15-16 decimal digits<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val percentage: Float = 99.5F\nval pi: Double = 3.14159265358979<\/code><\/pre>\n\n\n\n<p>Note the&nbsp;<code>F<\/code>&nbsp;suffix for Float.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Character Type (<code>Char<\/code>)<\/strong><\/h2>\n\n\n\n<p>Represents a&nbsp;<strong>single Unicode character<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val initial: Char = 'K'<\/code><\/pre>\n\n\n\n<p>Characters use&nbsp;<strong>single quotes<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Boolean Type (<code>Boolean<\/code>)<\/strong><\/h2>\n\n\n\n<p>Stores logical values:&nbsp;<strong>true<\/strong>&nbsp;or&nbsp;<strong>false<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val isOnline: Boolean = true\nval isSubscribed = false<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. Strings in Kotlin<\/strong><\/h2>\n\n\n\n<p>Strings are sequences of characters enclosed in double quotes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val name = \"Lawson\"<\/code><\/pre>\n\n\n\n<p>Kotlin also supports&nbsp;<strong>string templates<\/strong>, allowing you to insert variables directly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val age = 25\nprintln(\"My name is $name and I am $age years old.\")<\/code><\/pre>\n\n\n\n<p>For expressions, use&nbsp;<code>${ }<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">println(\"Next year I will be ${age + 1}\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Multi-line Strings<\/h2>\n\n\n\n<p>Use triple quotes&nbsp;<code>\"\"\"<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val message = \"\"\"\n    Hello Kotlin!\n    Welcome to multiline strings.\n\"\"\".trimIndent()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>7. Arrays<\/strong><\/h2>\n\n\n\n<p>An array stores multiple values of the same type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating arrays:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val numbers = arrayOf(1, 2, 3, 4)\nval names = arrayOf(\"Luke\", \"James\", \"Ada\")<\/code><\/pre>\n\n\n\n<p>Access elements:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">println(numbers[0])  \/\/ prints 1<\/code><\/pre>\n\n\n\n<p>Modify elements:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">numbers[1] = 20<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>8. Kotlin Collections (Important)<\/strong><\/h2>\n\n\n\n<p>Kotlin collections come in two major types:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Immutable Collections<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>listOf()<\/code><\/li>\n\n\n\n<li><code>setOf()<\/code><\/li>\n\n\n\n<li><code>mapOf()<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Mutable Collections<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>mutableListOf()<\/code><\/li>\n\n\n\n<li><code>mutableSetOf()<\/code><\/li>\n\n\n\n<li><code>mutableMapOf()<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Example:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val fruits = listOf(\"Apple\", \"Orange\")         \/\/ cannot change\nval numbers = mutableListOf(1, 2, 3)           \/\/ can change\nnumbers.add(4)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>9. Kotlin Null Safety<\/strong><\/h2>\n\n\n\n<p>Kotlin has built-in protection against null pointer exceptions.<\/p>\n\n\n\n<p>By default, variables&nbsp;<strong>cannot hold null<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val name: String = \"Luke\"\n\/\/ name = null  \u274c error<\/code><\/pre>\n\n\n\n<p>To allow null, you must add&nbsp;<code>?<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">var middleName: String? = null<\/code><\/pre>\n\n\n\n<p>You must safely handle nullable variables using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>?.<\/code>\u00a0(safe call)<\/li>\n\n\n\n<li><code>?:<\/code>\u00a0(Elvis operator)<\/li>\n\n\n\n<li><code>!!<\/code>\u00a0(non-null assertion \u2013 risky)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">println(middleName?.length)   \/\/ safe call (returns null)\nprintln(middleName ?: \"N\/A\")  \/\/ Elvis (default value)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>10. Type Conversion<\/strong><\/h2>\n\n\n\n<p>Kotlin does&nbsp;<strong>not<\/strong>&nbsp;automatically convert between different types.<\/p>\n\n\n\n<p>To convert:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">val num = \"123\".toInt()\nval amount = 45.toDouble()<\/code><\/pre>\n\n\n\n<p>Common conversion functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>toInt()<\/code><\/li>\n\n\n\n<li><code>toLong()<\/code><\/li>\n\n\n\n<li><code>toFloat()<\/code><\/li>\n\n\n\n<li><code>toDouble()<\/code><\/li>\n\n\n\n<li><code>toString()<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>11. Putting It All Together (Example Program)<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"kotlin\" class=\"language-kotlin\">fun main() {\n\n    val name: String = \"Kotlin Student\"\n    var score: Int = 90\n\n    val pi = 3.14      \/\/ inferred as Double\n    val isActive = true\n\n    var nickname: String? = null\n\n    val numbers = mutableListOf(1, 2, 3)\n    numbers.add(4)\n\n    println(\"Name: $name\")\n    println(\"Score: $score\")\n    println(\"PI: $pi\")\n    println(\"Active: $isActive\")\n    println(\"Nickname: ${nickname ?: \"No nickname\"}\")\n    println(\"Numbers: $numbers\")\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Summary<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Concept<\/th><th>Explanation<\/th><\/tr><\/thead><tbody><tr><td><code>val<\/code><\/td><td>Immutable variable<\/td><\/tr><tr><td><code>var<\/code><\/td><td>Mutable variable<\/td><\/tr><tr><td>Type inference<\/td><td>Kotlin automatically detects types<\/td><\/tr><tr><td>Basic Types<\/td><td>Int, Double, Boolean, Char, String<\/td><\/tr><tr><td>Nullable types<\/td><td>Use&nbsp;<code>?<\/code>&nbsp;to allow null<\/td><\/tr><tr><td>Collections<\/td><td>Immutable vs mutable lists, sets, maps<\/td><\/tr><tr><td>Type conversion<\/td><td>Manual conversions needed<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps, and<\/p>\n","protected":false},"author":1,"featured_media":3178,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24,98,95],"tags":[],"class_list":["post-3177","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-softare-development","category-software-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Kotlin Variables and Data Types<\/title>\n<meta name=\"description\" content=\"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kotlin Variables and Data Types\" \/>\n<meta property=\"og:description\" content=\"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-25T15:07:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-25T15:07:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1080\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"Kotlin Variables and Data Types\",\"datePublished\":\"2025-11-25T15:07:41+00:00\",\"dateModified\":\"2025-11-25T15:07:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/\"},\"wordCount\":497,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/2-14.png\",\"articleSection\":[\"programming\",\"softare development\",\"software development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/\",\"name\":\"Kotlin Variables and Data Types\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/2-14.png\",\"datePublished\":\"2025-11-25T15:07:41+00:00\",\"dateModified\":\"2025-11-25T15:07:43+00:00\",\"description\":\"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/2-14.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/2-14.png\",\"width\":1080,\"height\":1080,\"caption\":\"Kotlin variables and data types\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/kotlin-variables-and-data-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"programming\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/programming\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Kotlin Variables and Data Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kotlin Variables and Data Types","description":"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/","og_locale":"en_US","og_type":"article","og_title":"Kotlin Variables and Data Types","og_description":"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps","og_url":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2025-11-25T15:07:41+00:00","article_modified_time":"2025-11-25T15:07:43+00:00","og_image":[{"width":1080,"height":1080,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","type":"image\/png"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"Kotlin Variables and Data Types","datePublished":"2025-11-25T15:07:41+00:00","dateModified":"2025-11-25T15:07:43+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/"},"wordCount":497,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","articleSection":["programming","softare development","software development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/","url":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/","name":"Kotlin Variables and Data Types","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","datePublished":"2025-11-25T15:07:41+00:00","dateModified":"2025-11-25T15:07:43+00:00","description":"Kotlin is a modern, concise, and type-safe programming language used for Android development, backend systems, desktop apps","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","width":1080,"height":1080,"caption":"Kotlin variables and data types"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/kotlin-variables-and-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"programming","item":"https:\/\/codeflarelimited.com\/blog\/programming\/"},{"@type":"ListItem","position":3,"name":"Kotlin Variables and Data Types"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2025\/11\/2-14.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=3177"}],"version-history":[{"count":1,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3177\/revisions"}],"predecessor-version":[{"id":3179,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/3177\/revisions\/3179"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/3178"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=3177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=3177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=3177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}