23 阅读1分钟
  1. package
  2. 类似于文件夹
  3. 在某个包下面新建的文件,会自动在开头的部分添加 package 说明
  4. 在不同的包之间,移动文件,也能自动更新头部的 package 说明 import 导入 把别的包下的资源(其他文件夹下的文件) 导入到当前文件中使用!
// 1. 导入一个类
// import tools.A

// 2. 导入多个 {类1 类2 ....}
// import tools.{B, C, Student}

// 3. 导入一个包下所有的类 包名._
import tools._

// 4. 导入之后重新命名 格式: 包.{类名=>新名字}
import tools.{Student => NewStudent}
import tools.art.student

object demo02 {
  def main(args: Array[String]): Unit = {
    new A()
    new B()
    new C()

    var s1 = new NewStudent()
    s1.test()
  }