日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

查看scala变量数据类型_Scala文字,变量和数据类型| Scala编程教程

發布時間:2025/3/11 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 查看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 = 10LHexadecimal 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.35fDouble 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 Helpis 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 changedval 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變量數據類型

總結

以上是生活随笔為你收集整理的查看scala变量数据类型_Scala文字,变量和数据类型| Scala编程教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。