Scala 键盘输入语句

object compute {
  def main(args: Array[String]): Unit = {
    import  scala.io.StdIn
    //  Scala从控制台读取数据
    println("name")
    val name = StdIn.readLine()
    println("age")
    val age = StdIn.readInt()
    println("salary")
    val salary = StdIn.readDouble()
    //Java 从 控制台读取数据
    System.out.println("name")
    val scanner= new Scanner(System.in)
    val nameJ= scanner.next()
    System.out.println("age")
    val ageJ = scanner.next()
    System.out.println("salary")
    val salaryJ = scanner.next()
  }
}

 

你可能感兴趣的:(Scala)