{"id":177,"date":"2021-12-31T14:18:09","date_gmt":"2021-12-31T14:18:09","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/scala\/?p=177"},"modified":"2026-10-29T01:30:47","modified_gmt":"2026-10-29T01:30:47","slug":"scala-data-types","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/","title":{"rendered":"Scala &#8211; Data Types"},"content":{"rendered":"<p>Since Scala has some similarity with Java, it is no surprise that it has the same data types as in Java. Although there are a few additional data types.<\/p>\n<p>We cover the following sub-topics:<\/p>\n<ol>\n<li><a href=\"#t1\">Scala Data Types<\/a><\/li>\n<li><a href=\"#t2\">Literals in Scala<\/a><\/li>\n<li><a href=\"#t3\">Escape Sequences<\/a><\/li>\n<\/ol>\n<h4><strong id=\"t1\">1. Scala Data Types<\/strong><\/h4>\n<p>The table below gives a list of Scala data types.<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>Data Type<\/th>\n<th>Brief Description<\/th>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Byte<\/b><\/td>\n<td>8 bit signed value. Range from -128 to 127<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Short<\/b><\/td>\n<td>16 bit signed value. Range -32768 to 32767<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Int<\/b><\/td>\n<td>32 bit signed value. Range -2147483648 to 2147483647<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Long<\/b><\/td>\n<td>64 bit signed value. -9223372036854775808 to 9223372036854775807<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Float<\/b><\/td>\n<td>32 bit IEEE 754 single-precision float<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Double<\/b><\/td>\n<td>64 bit IEEE 754 double-precision float<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Char<\/b><\/td>\n<td>16 bit unsigned Unicode character. Range from U+0000 to U+FFFF<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>String<\/b><\/td>\n<td>A sequence of Chars<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Boolean<\/b><\/td>\n<td>Either the literal true or the literal false<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Unit<\/b><\/td>\n<td>Corresponds to no value<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Null<\/b><\/td>\n<td>null or empty reference<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Nothing<\/b><\/td>\n<td>The subtype of every other type; includes no values<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>Any<\/b><\/td>\n<td>The supertype of any type; any object is of type\u00a0<i>Any<\/i><\/td>\n<\/tr>\n<tr>\n<td class=\"ts\"><b>AnyRef\u00a0<\/b><\/td>\n<td>The supertype of any reference type<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Just like in Python, all data types in Scala are object data types<\/p>\n<p>It is also good to know that that the data types in Scala are objects. Also called reference types or non-primitive types. This means that the<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Literals in Scala<\/strong><\/h4>\n<p>Literals are used to define a constant value for example &#8216;Kindson&#8217;, 0.023, 120.<\/p>\n<p>Let&#8217;s take a look at some of the basic literals in Scala programming language.<\/p>\n<p>Int Literals &#8211; These are values without a decimal point. I could be of type Long when suffixed by L or l. Otherwise it is an Int<\/p>\n<p><strong>Floating Point Literals<\/strong> &#8211; These are floating point values which maybe sometimes followed by the suffix F or\u00a0 f. When followed by a suffix, it is a Float, otherwise it is a double.<\/p>\n<p><strong>Boolean Literals<\/strong> &#8211; Boolean literals are <strong>true<\/strong> or <strong>false<\/strong> values<\/p>\n<p><strong>Symbol Literals<\/strong> &#8211; A symbol literal &#8216;x&#8217; in scala represents the expression scala.Symbol(&#8220;x&#8221;)<\/p>\n<p><strong>Character Literals<\/strong> &#8211; Character literals in Scala is enclosed in single quotes. For example &#8216;A&#8217;, &#8216;2&#8217;. The character could also be an escape sequence (&#8216;\\n&#8217; for example) or unicode characters (&#8216;\\u0041&#8217;) for example.<\/p>\n<p><strong>String Literals<\/strong> &#8211; Just like in Java, String literals in Scala is enclosed in double quotes.<\/p>\n<p><strong>Multi-line Strings<\/strong> &#8211; A multi-line string in Scala begins with tripple double quotes (&#8220;&#8221;&#8221;) and ends with same. An example is given below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"background-color: #fff0f0;\">\"\"\"this is example <\/span>\r\n<span style=\"background-color: #fff0f0;\"> of multi-line string<\/span>\r\n<span style=\"background-color: #fff0f0;\">in scala programming.\"\"\"<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Null Values<\/strong> &#8211; Null value is scala is of type scala.Null. It represents a reference to a special &#8220;null&#8221; object<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Escape Sequences<\/strong><\/h4>\n<p>An escape sequence is a sequence of characters that when used within a string, translates to another character or sequence which would otherwise be difficult to represent directly. For instance, &#8216;\\n&#8217; translates a newline.<\/p>\n<p>The table below provides a list of escape sequences in Scala.<\/p>\n<p>&nbsp;<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>Escape Sequences<\/th>\n<th>Unicode<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>\\n<\/td>\n<td>\\u000c<\/td>\n<td>newline NL (Form feed)<\/td>\n<\/tr>\n<tr>\n<td>\\t<\/td>\n<td>\\u0009<\/td>\n<td>horizontal tab HT<\/td>\n<\/tr>\n<tr>\n<td>\\b<\/td>\n<td>\\u0008<\/td>\n<td>backspace BS<\/td>\n<\/tr>\n<tr>\n<td>\\f<\/td>\n<td>\\u000c<\/td>\n<td>formfeed FF<\/td>\n<\/tr>\n<tr>\n<td>\\r<\/td>\n<td>\\u000d<\/td>\n<td>carriage return CR<\/td>\n<\/tr>\n<tr>\n<td>\\&#8221;<\/td>\n<td>\\u0022<\/td>\n<td>double quote &#8220;<\/td>\n<\/tr>\n<tr>\n<td>\\&#8217;<\/td>\n<td>\\u0027<\/td>\n<td>single quote .<\/td>\n<\/tr>\n<tr>\n<td>\\\\<\/td>\n<td>\\u005c<\/td>\n<td>backslash \\<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Since Scala has some similarity with Java, it is no surprise that it has the same data types as in Java. Although there are a &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2],"tags":[25],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-scala-programming","tag-data-types"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scala - Data Types | Kindson The Genius<\/title>\n<meta name=\"description\" content=\"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scala - Data Types | Kindson The Genius\" \/>\n<meta property=\"og:description\" content=\"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Scala Programming\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-31T14:18:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-29T01:30:47+00:00\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/#\\\/schema\\\/person\\\/d69f73eca381222e2124581298dff5b4\"},\"headline\":\"Scala &#8211; Data Types\",\"datePublished\":\"2021-12-31T14:18:09+00:00\",\"dateModified\":\"2026-10-29T01:30:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/\"},\"wordCount\":500,\"keywords\":[\"Data Types\"],\"articleSection\":[\"Scala Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/\",\"name\":\"Scala - Data Types | Kindson The Genius\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/#website\"},\"datePublished\":\"2021-12-31T14:18:09+00:00\",\"dateModified\":\"2026-10-29T01:30:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/#\\\/schema\\\/person\\\/d69f73eca381222e2124581298dff5b4\"},\"description\":\"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/scala-data-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scala &#8211; Data Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/#website\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/\",\"name\":\"Scala Programming\",\"description\":\"Scala Programing Tutorials\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/#\\\/schema\\\/person\\\/d69f73eca381222e2124581298dff5b4\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/scala\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scala - Data Types | Kindson The Genius","description":"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.","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:\/\/kindsonthegenius.com\/scala\/scala-data-types\/","og_locale":"en_US","og_type":"article","og_title":"Scala - Data Types | Kindson The Genius","og_description":"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.","og_url":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/","og_site_name":"Scala Programming","article_published_time":"2021-12-31T14:18:09+00:00","article_modified_time":"2026-10-29T01:30:47+00:00","author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/#article","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/kindsonthegenius.com\/scala\/#\/schema\/person\/d69f73eca381222e2124581298dff5b4"},"headline":"Scala &#8211; Data Types","datePublished":"2021-12-31T14:18:09+00:00","dateModified":"2026-10-29T01:30:47+00:00","mainEntityOfPage":{"@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/"},"wordCount":500,"keywords":["Data Types"],"articleSection":["Scala Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/","url":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/","name":"Scala - Data Types | Kindson The Genius","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/scala\/#website"},"datePublished":"2021-12-31T14:18:09+00:00","dateModified":"2026-10-29T01:30:47+00:00","author":{"@id":"https:\/\/kindsonthegenius.com\/scala\/#\/schema\/person\/d69f73eca381222e2124581298dff5b4"},"description":"Scala - Data Types \u2014 free Scala tutorial by Kindson Munonye with clear examples. Step-by-step for beginners. Part of Kindson The Genius. Free online.","breadcrumb":{"@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kindsonthegenius.com\/scala\/scala-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kindsonthegenius.com\/scala\/"},{"@type":"ListItem","position":2,"name":"Scala &#8211; Data Types"}]},{"@type":"WebSite","@id":"https:\/\/kindsonthegenius.com\/scala\/#website","url":"https:\/\/kindsonthegenius.com\/scala\/","name":"Scala Programming","description":"Scala Programing Tutorials","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kindsonthegenius.com\/scala\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kindsonthegenius.com\/scala\/#\/schema\/person\/d69f73eca381222e2124581298dff5b4","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/kindsonthegenius.com\/scala\/author\/kindsonthegenius-3\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":178,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/posts\/177\/revisions\/178"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/scala\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}