scala <软件包>

53 阅读1分钟
package jhart

//导入
//别的文件中的类 对象 特质
//同一个包下面的文件 相互之间不需要import

//1.同时导入多个类:import 包 {类1,类2}
//import jhart.com.model.Student
//import jhart.com.model.Teacher

//2.同时导入包下的所有的类
import jhart.com.model._

//3.导入类后 重命名
import jhart.com.model.{Student => Stu}

object Test{

  class Student() {
    println("Student")
  }

  def main(args: Array[String]): Unit = {
    //不需要import 因为Student和当前测试文件在同一包下面
    new Stu()
    new Student()
    new Teacher()
  }
}

image.png