scala char_Scala中的Char數據類型

scala char

Scala Char數據類型 (Scala Char Data Type)

Character (char) in Scala is a data type that is equivalent to 16-bit unsigned integer. The character data type stores a single character. It can be an alphabet, numbers, symbols, etc. The character takes 2 bytes while storing its literals.

Scala中的字符(char)是相當于16位無符號整數的數據類型。 字符數據類型存儲單個字符。 它可以是字母,數字,符號等。該字符在存儲其文字時占用2個字節。

When stored in memory, the character data type is stored as a Unicode number. This Unicode number is a unique unification number that is available for every character literal to be stored.

當存儲在內存中時, 字符數據類型將存儲為Unicode數字。 該Unicode編號是唯一的統一編號,可用于要存儲的每個字符文字。

The use of char data type is not mandatory in scala. You can use var or val keyword in Scala to initialize them.

在scala中,不是必須使用char數據類型 。 您可以在Scala中使用var或val關鍵字進行初始化。

Syntax to define char variable in Scala:

在Scala中定義char變量的語法:

    //With data type
var variable_name : Char  = 'I';
//Without data type
val variable_name = 'i';

Example code to show Char data type in Scala

在Scala中顯示Char數據類型的示例代碼

object MyClass {
def main(args: Array[String]) {
var ch = 'I';
println("The value of character ch is "+ch);
ch = 'H';
println("The changed value of character ch is " + ch);
}
}

Output

輸出量

The value of character ch is I
The changed value of character ch is H

Code logic:

代碼邏輯:

The above code is used to show initialization and operation on Scala char data type. The code initializes the value 'I' to a variable ch and then prints "The value of character ch is I". After that, it changes the value if ch from 'I' to 'H' and then again prints the changed value.

上面的代碼用于顯示Scala char數據類型的初始化和操作。 該代碼將值“ I”初始化為變量ch ,然后輸出“字符ch的值為I” 。 之后,如果ch從“ I”更改為“ H” ,它將更改值,然后再次打印更改后的值。

翻譯自: https://www.includehelp.com/scala/char-data-type-in-scala.aspx

scala char

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377238.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377238.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377238.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

《MySQL——給長字符串加索引》

對于長字符串,可用如下方式建立索引: (1)前綴索引 (2)字符串倒敘前綴索引 (3)添加hash字段并在hash字段上加索引 (4)字段拆分(一個字段可拆分為兩…

[藍橋杯歷屆試題] 歐拉與雞蛋

大數學家歐拉在集市上遇到了本村的兩個農婦,每人跨著個空籃子。她們和歐拉打招呼說兩人剛剛賣完了所有的雞蛋。 歐拉隨便問:“賣了多少雞蛋呢?” 不料一個說:“我們兩人自己賣自己的,一共賣了150個雞蛋,雖然…

Python元組練習

Here, we are covering following Python tuple exercises, 在這里,我們將介紹以下Python元組練習 , Creating & printing a tuple 創建和打印元組 Unpacking the tuple into strings 將元組解包成字符串 Create a tuple containing the letters of…

傻瓜教你看清MVC內部執行流程之ViewData數據傳輸,輕松學MVC--①目了然篇(待續)

1.首先在執行到Controller里面的action(方法)時,執行到最后會調用一個View()-->此方法是Controller的一個方法 源代碼: View Code protected internal ViewResult View(){return View(null /* viewName */, null /* masterName */, null /* model */);} 2.然后繼續調用自己…

《MySQL——count()邏輯》

count()用法 count()語義:該函數為一個聚合函數,對于返回的結果集一行行地判斷,如果count函數地參數不是NULL,累計值就加1,否則不加。最后返回累計值。 所以count(*),count(主鍵id)和count(1)都表示返回滿足條件地結果…

phpmailer 發送郵件

<?php /* 可用新浪和網易郵箱測試成功&#xff0c;但QQ不成功&#xff01; 下載 phpmailer 解壓 http://phpmailer.worxware.com/要注意郵件服務器的端口號&#xff0c;默認是 25 不用修改&#xff0c;如果不是則要修改如下&#xff0c;在$mail->IsSMTP() ;下一行加上 $…

靜態負載均衡和動態負載均衡_動態負載平衡

靜態負載均衡和動態負載均衡動態負載平衡 (Dynamic Load Balancing) The algorithm monitors changes on the system workload and redistributes the work accordingly. 該算法監視系統工作負載的變化并相應地重新分配工作。 This algorithm works on three strategies: 該算…

poj 1088

題目&#xff1a;http://poj.org/problem?id1088 記憶化搜索&#xff0c;dp[r][c] max(dp[r - 1][c] , dp[r 1][c] , dp[r][c - 1] , dp[r][c 1]) 1 ( if (題目給的條件滿足&#xff09;&#xff09; View Code 1 using namespace std;2 typedef long long ll;3 const in…

《MySQL——order by邏輯(全字段排序與rowid排序)》

創建一個表&#xff0c;然后使用查詢語句&#xff1a; 查詢城市是“杭州”的所有人名字&#xff0c;并且按照姓名排序返回前 1000 個人的姓名、年齡 create table t (id int(11) not null,city vachar(16) not null,name vachar(16) not null,age vachar(16) not null,addr va…

ruby 生成哈希值_哈希== Ruby中的運算符

ruby 生成哈希值In the last article, we have seen how we can compare two hash objects with the help of < operator? "<" method is a public instance method defined in Rubys library. 在上一篇文章中&#xff0c;我們看到了如何在<運算符的幫助下…

HTML5 video

摘要&#xff1a;本文主要介紹HTML5 video在android2.2中實現的主要架構和程序流程。 一、實現HTML5 video主要的類 1&#xff0e; 主要類結構及介紹 圖1中綠色類為java類&#xff0c;其余為c類&#xff0c;下面是各個類的具體介紹: (1) HTMLElement類不是最上層類&#xff0c…

《MySQL——使用聯合索引、覆蓋索引,避免臨時表的排序操作》

聯合索引避免臨時表排序 在上一篇筆記(MySQL——order by邏輯&#xff08;全字段排序與rowid排序&#xff09;)中&#xff0c;講到查詢語句查詢多個字段的時候使用order by語句實現返回值是有序的&#xff0c;而order by是使用到了臨時表的&#xff0c;會帶來時間和空間損失。…

明源面試

明源面試&#xff0c;筆試題目如下 一、SQL測試題 1 有兩張表 根據給出的SQL語句&#xff0c;寫出返回的行數分別是多少&#xff1f;為了形象直觀的顯示&#xff0c;我給出了sql語句執行結果。 A 學生表 B分數表 新題目 select a.* from a inner join b on a.idb.id; …

AEAP的完整形式是什么?

AEAP&#xff1a;盡早 (AEAP: As Early As Possible) AEAP is an abbreviation of "As Early As Possible". AEAP是“ April越早”的縮寫 。 It is an expression, which is commonly used in messaging or chatting on social media networking sites like Faceboo…

jquery 視覺特效(鼠標懸停時依次顯示圖片)

效果描述&#xff1a; 有幾副圖片&#xff0c;讓他們依次疊加重合。首先顯示第一張圖片。然后鼠標懸停在上面&#xff0c;邊框變化。然后離開&#xff0c;然后第一張淡出&#xff0c;第二張淡入。接著懸停在第二張圖片&#xff0c;邊框變化&#xff0c;然后離開&#xff0c;第二…

《MySQL tips:查詢時,盡量不要對字段進行操作》

維護一個交易系統&#xff0c;交易記錄表tradelog包含交易流水號(tradeid)、交易員id(operator)、交易時間(t_modified)等字段。 建表語句如下&#xff1a; create table tradelog (id int(11) not null,tradeid varchar(32) default null,operator int(11) default null,t_mo…

cocos2dx blender 骨骼動畫實現

前言 cocos2d-x 中相關部分代碼介紹 背景知識介紹 參考 http://www.3dkingdoms.com/weekly/weekly.php?a4 一 簡單3d 模型支持 第一步實現對3d 模型的簡單支持&#xff0c;完成一個CCSprite3D 類 參考CCSprite 類 以及 CCGLProgram 代碼 主要修改 draw 方法。 添加了定點數組…

關于web.config中customErrors節點說明

關于web.config中<customErrors>節點說明 <customErrors>節點用于定義一些自定義錯誤信息的信息。此節點有Mode和defaultRedirect兩個屬性&#xff0c;其中defaultRedirect屬性是一個可選屬性&#xff0c;表示應用程序發生錯誤時重定向到的默認URL&#xff0c;如果…

肯德基收銀系統模式_肯德基的完整形式是什么?

肯德基收銀系統模式肯德基&#xff1a;肯塔基炸雞 (KFC: Kentucky Fried Chicken) KFC is an abbreviation of "Kentucky Fried Chicken". It is a fast-food restaurant chain whose specialty is known for fried chicken because of its specialization in it. It…

泛型(CSDN轉載)

函數的參數不同叫多態&#xff0c;函數的參數類型可以不確定嗎&#xff1f; 函數的返回值只能是一個嗎&#xff1f;函數的返回值可以不確定嗎&#xff1f; 泛型是一種特殊的類型&#xff0c;它把指定類型的工作推遲到客戶端代碼聲明并實例化類或方法的時候進行。 下面是兩個經典…