{"id":5597,"date":"2020-09-30T10:33:14","date_gmt":"2020-09-30T10:33:14","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=5597"},"modified":"2024-04-11T10:55:19","modified_gmt":"2024-04-11T10:55:19","slug":"data-types-and-operators-in-scala-programming-language","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/","title":{"rendered":"Scala &#8211; Data types and operators"},"content":{"rendered":"\r\n<h2 class=\"wp-block-heading\"><span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Guide to Data Types in Scala&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:6145,&quot;3&quot;:{&quot;1&quot;:0,&quot;3&quot;:1},&quot;14&quot;:{&quot;1&quot;:3,&quot;3&quot;:1},&quot;15&quot;:&quot;Arial&quot;}\">Guide to Data Types in Scala<\/span><\/h2>\r\n<h3><strong>Data Types<\/strong><\/h3>\r\n\r\n\r\n\r\n<p>1. Byte: It is an 8 bit signed value.<\/p>\r\n\r\n\r\n\r\n<p>2. Short: It is a 16 bit signed value.<\/p>\r\n\r\n\r\n\r\n<p>3. Int: It is a 32 bit signed value.<\/p>\r\n\r\n\r\n\r\n<p>4. Long: It is a 64 bit signed value.<\/p>\r\n\r\n\r\n\r\n<p>5. Float: It can store 32 bit of data<\/p>\r\n\r\n\r\n\r\n<p>6. Double: It can store 64 bit of data<\/p>\r\n\r\n\r\n\r\n<p>7. Char: It is a 16 bit unsigned Unicode character.<\/p>\r\n\r\n\r\n\r\n<p>8. String: It is a sequence of Chars<\/p>\r\n\r\n\r\n\r\n<p>9. Boolean: It holds either of these values the literal true or the literal false<\/p>\r\n\r\n\r\n\r\n<p>10. Null: It holds empty reference or null<\/p>\r\n\r\n\r\n\r\n<p>12. Nothing: It is the subtype of every other data type which includes no values<\/p>\r\n\r\n\r\n\r\n<p>13. Any: It is the super type of any type where any object is of type Any<\/p>\r\n\r\n\r\n\r\n<p>14. AnyRef: It is the super type of any reference type No.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\"><strong>Operators<\/strong><\/h3>\r\n\r\n\r\n\r\n<p>An operator is a symbol that instructs the compiler to perform any mathematical or logical manipulations. Scala is rich in built-in operators and different types of operators are:<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\r\n<ol class=\"wp-block-list\">\r\n<li>Arithmetic Operators<\/li>\r\n<li>Relational Operators<\/li>\r\n<li>Logical Operators<\/li>\r\n<li>Bitwise Operators<\/li>\r\n<li>Assignment Operators<\/li>\r\n<\/ol>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<h4 class=\"has-medium-font-size\"><strong>Arithmetic Operators<\/strong><\/h4>\r\n\r\n\r\n\r\n<p>The following are the arithmetic operators supported by Scala language.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>Operator<\/strong><\/td>\r\n<td><strong>Description<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td>+<\/td>\r\n<td>Adds two operands<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8211;<\/td>\r\n<td>Subtracts second operand from the first<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>*<\/td>\r\n<td>Multiplies both the operands<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\/<\/td>\r\n<td>Divides numerator by de-numerator<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>%<\/td>\r\n<td>Modulus operator finds the remainder after division of one number by another<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>For example, if variables A=6 and B=16, then<\/p>\r\n\r\n\r\n\r\n\r\n\r\n<h4 class=\"has-medium-font-size\"><strong>Relational Operators<\/strong><\/h4>\r\n\r\n\r\n\r\n<p>The following are the relational operators supported by Scala language.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td>Operator<\/td>\r\n<td>Description<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>==<\/td>\r\n<td>Checks if the values of two operands are equal or not, if yes then condition becomes true else False.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>!=<\/td>\r\n<td>Checks if the values of two operands are equal or not, if values are not equal then condition becomes true else False.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&gt;\u00a0<\/td>\r\n<td>Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;\u00a0<\/td>\r\n<td>Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&gt;=<\/td>\r\n<td>Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;=<\/td>\r\n<td>Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>For example, if variables A=6 and B=16, then<\/p>\r\n\r\n\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<h4><strong>Logical Operators<\/strong><\/h4>\r\n\r\n\r\n\r\n<p>The following logical operators are supported by Scala language.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>Operator<\/strong><\/td>\r\n<td><strong>Description<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&amp;&amp;<\/td>\r\n<td>It is called Logical AND operator. If both the operands are non-zero then condition becomes true.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>||<\/td>\r\n<td>It is called Logical OR Operator. If any of the two operands is non zero then condition becomes true.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>!<\/td>\r\n<td>It is called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>For example, if variables b1=true and b2=false, then<\/p>\r\n\r\n\r\n\r\n\r\n\r\n<p><strong>Prog1. Define 1 to natural numbers and sum them.<\/strong><\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\r\n<ul class=\"blocks-gallery-grid\">\r\n<li class=\"blocks-gallery-item\">\u00a0<\/li>\r\n<\/ul>\r\n<\/figure>\r\n\r\n\r\n\r\n<p><strong>Prog2. Define 50 numbers which should <a href=\"https:\/\/prwatech.in\/blog\/\">start<\/a> from 0 and <a href=\"https:\/\/www.tableau.com\/\">find<\/a> out only odd numbers. Then multiply all odd numbers with 2 and sum all of them.<\/strong><\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\r\n<ul class=\"blocks-gallery-grid\">\r\n<li class=\"blocks-gallery-item\">\u00a0<\/li>\r\n<\/ul>\r\n<\/figure>\r\n","protected":false},"excerpt":{"rendered":"<p>Guide to Data Types in Scala Data Types 1. Byte: It is an 8 bit signed value. 2. Short: It is a 16 bit signed value. 3. Int: It is a 32 bit signed value. 4. Long: It is a 64 bit signed value. 5. Float: It can store 32 bit of data 6. Double: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[565,1698],"tags":[1977,1976,1978,1979],"class_list":["post-5597","post","type-post","status-publish","format-standard","hentry","category-scala","category-scala-modules-scala","tag-a-few-built-in-types-scala-book","tag-basic-types-in-scala-tutorial","tag-data-types-in-scala","tag-scala-data-types"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Guide to Data Types in Scala - Prwatech<\/title>\n<meta name=\"description\" content=\"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Guide to Data Types in Scala - Prwatech\" \/>\n<meta property=\"og:description\" content=\"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-30T10:33:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-11T10:55:19+00:00\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\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\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/\",\"url\":\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/\",\"name\":\"Guide to Data Types in Scala - Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"datePublished\":\"2020-09-30T10:33:14+00:00\",\"dateModified\":\"2024-04-11T10:55:19+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scala &#8211; Data types and operators\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Guide to Data Types in Scala - Prwatech","description":"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Guide to Data Types in Scala - Prwatech","og_description":"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","og_url":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2020-09-30T10:33:14+00:00","article_modified_time":"2024-04-11T10:55:19+00:00","author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/","url":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/","name":"Guide to Data Types in Scala - Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"datePublished":"2020-09-30T10:33:14+00:00","dateModified":"2024-04-11T10:55:19+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Master Guide to Data Types in Scala - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/scala\/scala-modules-scala\/data-types-and-operators-in-scala-programming-language\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Scala &#8211; Data types and operators"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/5597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=5597"}],"version-history":[{"count":9,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/5597\/revisions"}],"predecessor-version":[{"id":11349,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/5597\/revisions\/11349"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=5597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=5597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=5597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}