上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 29 下一页
摘要: 1 package chapter08 2 3 object Test03_MatchTupleExtend { 4 def main(args: Array[String]): Unit = { 5 // 1. 在变量声明时匹配 6 val (x, y) = (10, "hello") 7 pri 阅读全文
posted @ 2022-01-20 21:11 靠谱杨 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter08 2 3 object Test02_MatchTypes { 4 def main(args: Array[String]): Unit = { 5 // 1. 匹配常量 6 def describeConst(x: Any): String = x matc 阅读全文
posted @ 2022-01-20 21:09 靠谱杨 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test18_ComplexWordCount { 4 def main(args: Array[String]): Unit = { 5 val tupleList: List[(String, Int)] = List( 6 ("he 阅读全文
posted @ 2022-01-20 20:34 靠谱杨 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test17_CommonWordCount { 4 def main(args: Array[String]): Unit = { 5 val stringList: List[String] = List( 6 "hello", 7 阅读全文
posted @ 2022-01-20 20:19 靠谱杨 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test15_HighLevelFunction_Reduce { 4 def main(args: Array[String]): Unit = { 5 val list = List(1,2,3,4) 6 7 // 1. reduce 阅读全文
posted @ 2022-01-20 16:53 靠谱杨 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test14_HighLevelFunction_Map { 4 def main(args: Array[String]): Unit = { 5 val list = List(1,2,3,4,5,6,7,8,9) 6 7 // 1. 阅读全文
posted @ 2022-01-20 16:37 靠谱杨 阅读(488) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test10_Tuple { 4 def main(args: Array[String]): Unit = { 5 // 1. 创建元组 3元祖就是有3个元素 6 val tuple: (String, Int, Char, Boole 阅读全文
posted @ 2022-01-19 21:26 靠谱杨 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 import scala.collection.mutable 4 5 object Test09_MutableMap { 6 def main(args: Array[String]): Unit = { 7 // 1. 创建map 8 val m 阅读全文
posted @ 2022-01-19 21:20 靠谱杨 阅读(1299) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test08_ImmutableMap { 4 def main(args: Array[String]): Unit = { 5 // 1. 创建map 使用伴生对象( ) Map默认就是Immutable.Map不可变 6 val m 阅读全文
posted @ 2022-01-19 21:03 靠谱杨 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 import scala.collection.mutable 4 5 object Test07_MutableSet { 6 def main(args: Array[String]): Unit = { 7 // 1. 创建setmutable. 阅读全文
posted @ 2022-01-19 12:03 靠谱杨 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test06_ImmutableSet { 4 def main(args: Array[String]): Unit = { 5 // 1. 创建set 直接使用括号() apply的作用 6 val set1 = Set(13, 23 阅读全文
posted @ 2022-01-19 12:01 靠谱杨 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 import scala.collection.mutable.ListBuffer 4 5 object Test05_ListBuffer { 6 def main(args: Array[String]): Unit = { 7 // 1. 创建 阅读全文
posted @ 2022-01-19 11:49 靠谱杨 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 object Test04_List { 4 def main(args: Array[String]): Unit = { 5 // 1. 创建一个List 6 val list1 = List(23, 65, 87) 7 println(list1 阅读全文
posted @ 2022-01-19 11:45 靠谱杨 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter07 2 3 import scala.collection.mutable 4 import scala.collection.mutable.ArrayBuffer 5 6 object Test02_ArrayBuffer { 7 def main(args: 阅读全文
posted @ 2022-01-18 22:58 靠谱杨 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2022-01-18 22:33 靠谱杨 阅读(82) 评论(0) 推荐(1) 编辑
摘要: (1)obj.isInstanceOf[T]:判断 obj 是不是 T 类型。 (2)obj.asInstanceOf[T]:将 obj 强转成 T 类型。 (3)classOf 获取对象的类名。 1 package chapter06 2 3 object Test17_Extends { 4 d 阅读全文
posted @ 2022-01-18 19:33 靠谱杨 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter06 2 3 object Test16_TraitSelfType { 4 def main(args: Array[String]): Unit = { 5 val user = new RegisterUser("alice", "123456") 6 use 阅读全文
posted @ 2022-01-18 19:27 靠谱杨 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter06 2 3 object Test13_Trait { 4 def main(args: Array[String]): Unit = { 5 val student: Student13 = new Student13 6 student.sayHello() 阅读全文
posted @ 2022-01-18 18:44 靠谱杨 阅读(39) 评论(0) 推荐(0) 编辑
摘要: 一、包 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]): 阅读全文
posted @ 2022-01-18 17:15 靠谱杨 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 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. 函数 阅读全文
posted @ 2022-01-18 12:51 靠谱杨 阅读(51) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 29 下一页