
scala
eiffel_0311
这个作者很懒,什么都没留下…
展开
-
scala------数组映射和元组
一. 数组 1. 定长数组 var array = new Array[Int](10) var array = Array("1", "2") 2. 变长数组 import scala.collection.mutable.ArrayBuffer val b = ArrayBuffer[Int]() b += (1, 2原创 2016-02-16 15:11:21 · 82112 阅读 · 0 评论 -
scala------基础:流程控制和函数
Hello World, test.scala :object Test { def main(args: Array[String]): Unit = { println("Hello World") }} 编译: scalac test.scala 运行: scala Test 1. 条件控制原创 2016-02-16 14:45:47 · 82120 阅读 · 0 评论 -
scala------ 类和对象
一. 对象1. getter 和 setter, public 字段自带这两个方法, age 拥有age, age= 两个方法 name 只有name= 方法, address 拥有address, address= , getAddress(), setAddress(newValue: String) 方法import scala.reflec原创 2016-02-16 18:08:47 · 81651 阅读 · 0 评论 -
scala------包和引入
1. 包的作用:命名空间控制,及访问控制package com{ package horstmann{ class Employee{ def t1() = { println("i am t1") } def t3() = {原创 2016-02-17 09:54:59 · 80175 阅读 · 0 评论 -
scala------ 继承
1. 继承class Person { def myName():String ={ "haha" }}class Student extends Person { override def myName():String = { // 重写的方法必须加override "Haha1" }}obje原创 2016-02-17 10:34:31 · 80693 阅读 · 0 评论 -
scala------高阶函数
1. 匿名函数 Array(1, 2, 3).map((x: Int) => 3*x) 中 (x: Int) => 3*x 为匿名函数2. 以函数作为参数的函数class Test1 { def t1(f1: (Int) => Int, f2: (Int) => Int, x: Int, y:Int) = { f1(x) + f2(y)原创 2016-02-22 08:53:36 · 80320 阅读 · 0 评论 -
scala------集合
1. 集合 序列(seq):有先后次序的序列 val l = List(1, 2, 3) 集合(set):没有先后顺序的序列 val s = Set(1, 2, 3) 映射(map):键值对数据 var原创 2016-02-22 11:21:46 · 79738 阅读 · 0 评论 -
scala------match
1. 普通match object Test { def main(args: Array[String]): Unit = { val a = "c" a match { case "a" => println("a") case "c" => println("c") case _原创 2016-02-22 11:22:10 · 79096 阅读 · 0 评论 -
scala------类型参数
1. 泛型类 class Test1[T](val p1: T){ def t1():Unit = { println("there is " + p1) }}object Test { def main(args: Array[String]): Unit = { val t1 = new Test1("haha")原创 2016-02-22 17:16:43 · 79039 阅读 · 0 评论