scala數據類型
阿新 • • 發佈:2018-04-19
sta big .com rtu 用法 bigint star 其它 log
# Scala數據類型
## 1.數值類型
### 1.1 與Java一樣Scala也有8種數值類型
* Byte
* Char
* Short
* Int
* Long
* Float
* Double
* Boolean
### 1.2 其它數值類型
* BigInt = java.math.BigInteger
* Decimal = java.math.BigDecimal
### 1.3 用法
* 1.4.toInt => 1
* 99.toChar => c
* ‘A‘.toInt => 65
### 1.4 操作符
a + b => a.+(b)
* \+
* \-
* \*
* \/
* \%
* \&
* \|
* \^
* \>>
* \<<
* +=
* -=
### 1.5 函數和方法
* __方法和對象相關,函數和對象無關。__
* 方法:
def method(age: Int): Unit = { println("Your age is " + age + ".") }
http://www.cnblogs.com/nowgood/p/scalastartup.html#_nav_3
def method(age: Int): Unit = { println("Your age is " + age + ".") }
http://www.cnblogs.com/nowgood/p/scalastartup.html#_nav_3
scala數據類型