scala--定义变量--重新赋值--编译器错误

C:\Users\Administrator>scala
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_421).
Type in expressions for evaluation. Or try :help.

scala> var x = 5
x: Int = 5

scala> x = "what's up?"
:12: error: type mismatch;
found : String("what's up?")
required: Int
x = "what's up?"
^

scala>

posted @ 2025-02-03 10:03  基础狗  阅读(9)  评论(0)    收藏  举报