查看scala變量數據類型_Scala文字,變量和數據類型| Scala編程教程

查看scala變量數據類型

1)Scala數據類型 (1) Scala Data Types)

Scala has the same set of data types as in Java. The traditional 14 data types are inherited as it is in Scala.

Scala具有與Java中相同的數據類型集。 傳統的14種數據類型在Scala中被繼承。

The Following are Valid Data Types in Scala.

以下是Scala中的有效數據類型。

S. No. Data TypeBit Size Range
1Byte8-128 to 127
2Short 16-32768 to 32767
3Int32-2147483648 to 2147483647
4Long 64-9223372036854775808 to 9223372036854775807
5Float 32IEEE 754 single-precision
6Double 64IEEE 754 double-precision
7Char 16Unicode : U+0000 to U+FFFF
8String *Char Sequence
9Boolean1true/ false
10Unit*No Value
11Null*Null / empty reference
12Nothing*Subtype, includes no value
13Any*any object
14AnyRef*reference type
序號 數據類型 位大小 范圍
1個 字節 8 -128至127
2 16 -32768至32767
3 整數 32 -2147483648至2147483647
4 64 -9223372036854775808至9223372036854775807
5 浮動 32 IEEE 754單精度
6 64 IEEE 754雙精度
7 燒焦 16 Unicode:U + 0000至U + FFFF
8 *字符序列
9 布爾型 1個 真假
10 單元 *沒有價值
11 空值 *空/空參考
12 沒有 *子類型,不包含任何值
13 任何 *任何物體
14 任何參考 *參考類型

2)Scala中的文字 (2) Literals in Scala)

A literal is a value that can be assigned to a variable. Literals are basic constants that are assigned to the variable.

文字是可以分配給變量的值。 文字是分配給變量的基本常量。

Types of literals

文字類型

  • Integer Literals: Literals of type int or type Long. Integer literals can be declared using suffix L or I.

    整數文字 :int類型或Long類型的文字。 整數文字可以使用后綴L或I聲明。

    Example:
Decimal Literal : var i = 10L
Hexadecimal Literal : var I = 0xFFF

  • Float Literals: Literals of type float or type double. They use Suffix f/F for float and D/d for double.

    Float字面量 :float或double類型的字面量。 他們將后綴f / F用于浮點,將D / d用于雙精度。

  •     Example:
    Float Literal : var i = 12.35f
    Double Literal : var I = 123.5445d
    
    
  • Character Literals: Unicode characters like 'f'

    字符字面量 :Unicode字符,例如“ f”

  • String Literal: Multiple character literal like 'Include'

    字符串文字 :多字符文字,例如“包含”

  • Multi-Line Literal: Muti-line string Literal.

    多行文字 :多行字符串Literal。

  •     Example:
    "Include Help
    is of the best 
    Programming tutor"
    
    
  • Boolean: A literal with any of two values, True/False.

    布爾值 :具有兩個值True / False的文字。

  • 3)Scala中的變量 (3) Variables in Scala)

    A variable is some space in the memory that stores values. The memory space allocated to the variable is based on its data type.

    變量是內存中存儲值的一些空間。 分配給變量的內存空間基于其數據類型。

    Declaration of variables in Scala

    在Scala中聲明變量

    In Scala, there are two types of variables 1) mutable (just like normal variables whose values can be changed during program execution) and 2) immutable (just like a constant whose value cannot be changed during program execution).

    在Scala中,有兩種類型的變量:1) 可變的 (就像在程序執行過程中可以更改其值的普通變量一樣)和2) 不可變的 (就像在程序執行過程中其值不能更改的常量一樣)。

    Mutable variables are declared by using the "var" keyword, and immutable variables are declared by using the "val" keyword.

    可變變量使用“ var”關鍵字聲明,不可變變量使用“ val”關鍵字聲明

    Example:

    例:

        var I = 23 // this value can be changed
    val H = 12 //this value cannot be changed. 
    
    

    Although variable data type is detected by Scala but you can explicitly define it.

    盡管Scala檢測到可變數據類型,但是您可以顯式定義它。

        var I : string = "Include"
    val H : string = "Help"
    

    翻譯自: https://www.includehelp.com/scala/literal-variables-and-data-type.aspx

    查看scala變量數據類型

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

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

相關文章

Elasticsearch過濾與聚合的先后順序java實現

2019獨角獸企業重金招聘Python工程師標準>>> 一、Elasticsearch的聚合 ES的聚合相當于關系型數據庫里面的group by,例如查找在性別字段男女人數的多少并且按照人數的多少進行排序,在使用MySQL的時候,可以使用如下的句子 select se…

js手機號中間四位_11位手機號碼隱藏中間四位數,學會Substitute函數一鍵搞定!...

相信許多朋友都有見過手機號碼被*號隱藏中間四位數的情況。許多地方為了保護個人信息,都會將手機號的中間四位數用星號代替。如上圖所示,我們需要將原來的手機號碼,通過*號的方式變為隱藏后的加密模式。下面我們就來學習一下如何利用substitu…

python 整數最大_Python程序使用floor()方法查找最大整數

python 整數最大The greatest integer function is a function (real numbers function) to itself that is defined as follows: it sends any real number to the largest integer that is less than or equal to it. 最大整數函數是一個對其自身定義的函數(實數函數)&#x…

selinux對ftp的影響

1.啥是selinux 安全增強型Linux(Security-Enhanced Linux)簡稱selinux,它是一個Linux內核模塊,也是Linux的一個安全子系統。 selinux的狀態: Enforcing:強制模式,在selinux運作時,已經開始限制d…

ES6的class方法基本用法

為什么80%的碼農都做不了架構師?>>> 在ES5中我們通常通過構造函數,定義并生成新對象。 例如: function Point(name,age){this.namename;this.ageage;}Point.prototype{Who:function(){return "My name is "this.name",My age…

celery的中文_celery異步任務框架

目錄Celery一、官方二、Celery異步任務框架Celery架構圖消息中間件任務執行單元任務結果存儲三、使用場景四、Celery的安裝配置五、兩種celery任務結構:提倡用包管理,結構更清晰七、Celery執行異步任務包架構封裝八、基本使用celery.py 基本配置tasks.py…

關于linux mv指令機制

最近在mv文件的時候,操作失誤將生產服務器一個1TB的文件夾mv到了/opt/test目錄,因為最后/opt/目錄被沾滿所以1TB的文件夾沒有遷移過來,寫入了30GB數據到了/opt/test目錄,因為系統分區被沾滿,所以把test目錄給刪除了。 …

數據庫的管理

1. 數據庫的簡介 定義:數據庫(Database)就是一種按數據結構來組織,存儲和管理數據的倉庫,其中包含數據挖掘,大數據信息的推送。 mariadb數據庫管理系統是mysql的一個分支,主要由開源社區在維護&…

C#中的Dictionary字典類介紹(轉載)

C#中的Dictionary字典類介紹 關鍵字:C# Dictionary 字典 作者:txw1958原文:http://www.cnblogs.com/txw1958/archive/2012/11/07/csharp-dictionary.html 說明 必須包含名空間System.Collection.Generic Dictionary里面的每一個元素都…

求階乘的第一個非零數字_查找數字階乘中的尾隨零

求階乘的第一個非零數字Problem statement: 問題陳述: Find the number of trailing zeros in n! (Where, n is the given input). 在n中找到尾隨零的數目! (其中, n是給定的輸入)。 Solution: 解: Computing a factorial is o…

高速緩存dns

1. DNS: Domain Name System,域名系統。 萬維網上作為域名和IP地址相互映射的一個分布式數據庫,能夠使用戶更方便的訪問互聯網。他主要負責把域名和IP的相互轉換,DNS運行與TCP|UDP的53端口上。 2. 高速緩存DNS:DNS服務…

python log日志級別_python – 日志記錄:如何為處理程序設置最大日志級別

您可以向文件處理程序添加過濾器.這樣,您可以將特定級別重定向到不同的文件.import loggingclass LevelFilter(logging.Filter):def __init__(self, low, high):self._low lowself._high highlogging.Filter.__init__(self)def filter(self, record):if self._low < recor…

Python Pandas –合并,聯接和串聯

There are three main ways to combine dataFrames i.e., merging, joining and concatenating. The following examples will illustrate merging, joining and concatenation. 組合dataFrames的主要方法有三種&#xff0c;即合并&#xff0c;聯接和串聯 。 以下示例將說明合并…

Apache服務配置

1. apache 企業中常用的web服務。用來提供http&#xff1a;//&#xff08;超文本傳輸協議&#xff09; 基礎信息&#xff1a; 主配置目錄&#xff1a; /etc/httpd/conf 主配置文件&#xff1a; /etc/httpd/conf/httpd.conf 子配置目錄&#xff1a; /etc/httpd/conf.d/ 子配置文…

git 怎么查看合并過來哪些代碼_git整理紛亂的歷史合并記錄

https://github.com/Epix37/Hearthstone-Deck-Tracker以上面版本庫的master分支為例父節點1SHA-1: a21142968282ae49720cf30a0f18290b2ce74b3a* remove hotkey from config if action could not be found, fix hotkey menu item name父節點2SHA-1: 86a824e8f46005db91f334dfc57…

如何安裝Genymotion虛擬機以及Genmotion的eclipse插件

---內容開始--- - 首先去genymotion的官網去下載其安裝文件 資源下載 Genymotion官網必須注冊一個賬號這個賬號安裝之后還有用的&#xff0c;用戶名最好用網易126郵箱注冊----我下載的是2.8.0的版本(注&#xff1a;注冊前先開個代理服務器不然頁面打不開下載時最好用迅雷下載這…

java system類_Java System類mapLibraryName()方法及示例

java system類系統類mapLibraryName()方法 (System class mapLibraryName() method) mapLibraryName() method is available in java.lang package. mapLibraryName()方法在java.lang包中可用。 mapLibraryName() method is used to map a given library name into a platform-…

squid服務配置(正向、反向代理)

代理&#xff1a; 就是代理網絡用戶去取得網絡信息。 Squid是一種用來緩沖Internet數據的軟件。安裝Squid服務實現代理緩存服務器功能。 正向代理&#xff1a;意思是一個位于客戶端和原始服務器之間的服務器&#xff0c;為了從原始服務器取得內容&#xff0c;客戶端向代理發送一…

家譜整站源碼php_mysql家譜表查詢某人所有后代

CREATE TABLE people (id INT(11) NOT NULL,name VARCHAR(50) NULL DEFAULT NULL,pid INT(11) NOT NULL DEFAULT 0,PRIMARY KEY (id));CREATE DEFINERroot% PROCEDURE getChildren(IN parentId INT)LANGUAGE SQLNOT DETERMINISTICCONTAINS SQLSQL SECURITY DEFINERCOMMENT 獲取…

React 入門學習筆記2

摘自阮一峰&#xff1a;React入門實例教程&#xff0c;轉載請注明出處。 一、獲取真實的DOM節點 組件并不是真實的 DOM 節點&#xff0c;而是存在于內存之中的一種數據結構&#xff0c;叫做虛擬 DOM &#xff08;virtual DOM&#xff09;。只有當它插入文檔以后&#xff0c;才會…