摘要:
1 package chapter07 2 3 import scala.collection.mutable 4 import scala.collection.mutable.ArrayBuffer 5 6 object Test02_ArrayBuffer { 7 def main(args: 阅读全文
摘要:
1 package chapter07 2 3 object Test01_ImmutableArray { 4 def main(args: Array[String]): Unit = { 5 // 1. 创建数组 6 val arr: Array[Int] = new Array[Int](5 阅读全文
摘要:
(1)obj.isInstanceOf[T]:判断 obj 是不是 T 类型。 (2)obj.asInstanceOf[T]:将 obj 强转成 T 类型。 (3)classOf 获取对象的类名。 1 package chapter06 2 3 object Test17_Extends { 4 d 阅读全文
摘要:
1 package chapter06 2 3 object Test16_TraitSelfType { 4 def main(args: Array[String]): Unit = { 5 val user = new RegisterUser("alice", "123456") 6 use 阅读全文
摘要:
1 package chapter06 2 3 object Test13_Trait { 4 def main(args: Array[String]): Unit = { 5 val student: Student13 = new Student13 6 student.sayHello() 阅读全文
摘要:
一、包 1 package com{ 2 3 import com.atguigu.scala.Inner 4 5 // 在外层包中定义单例对象 6 object Outer{ 7 var out: String = "out" 8 9 def main(args: Array[String]): 阅读全文
摘要:
1 package com.atguigu.chapter04 2 3 object Test_Lazy { 4 def main(args: Array[String]): Unit = { 5 lazy val result : Int = sum(13,12) 6 println("1. 函数 阅读全文
摘要:
1 package com.atguigu.function 2 3 object Recursion { 4 def main(args: Array[String]): Unit = { 5 // 阶乘 6 // 递归算法 7 // 1) 方法调用自身 8 // 2) 方法必须要有跳出的逻辑 9 阅读全文
摘要:
1 package com.atguigu.chapter04 2 3 object ControlAbstraction { 4 def main(args: Array[String]): Unit = { 5 //1. 传值参数(传递计算后的值) 6 def f0(a:Int):Unit = 阅读全文