isPrime

28 阅读1分钟
scala

object w29 {

  def hello(name:String="小樊", age:Int, gender:String="女" ) = {
    println(s"hello, 我是${name},${age}岁 , 性别:${gender}")



  }

  def main(args: Array[String]): Unit = {
     hello("小胖",18,"男")
     hello("小胖",18,"男")
     hello("小胖",18)
    hello(age=18)




  }
}

屏幕截图 2025-10-11 092654.png

scala

object w30 {

  def getSum(args:Int*):Int = {
    var sum = 0
    for (i <- args){
      sum += i
    }
    sum
  }

  def main(args: Array[String]): Unit = {
    val result1 = getSum(1)
    val result2 = getSum(4,1,2,3,5)
    println(result1,result2)