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.mzph.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;它把指定类型的工作推迟到客户端代码声明并实例化类或方法的时候进行。 下面是两个经典…