scala学习笔记1

package com.scala.stu
/**
 * 第一章例子
 */
object t_001 {
  
  def main(args: Array[String]): Unit = {
    //定义一个函数指向一个匿名函数,测试while()一个循环
    xunhuan(10)
  }
  
  /**
   * 循环函数
   */
  def xunhuan(num : Int): Unit = {
    var a = num
    while(a>0){
      print(a)
      if(a != 1)
      print("-")
      a = a - 1
    }
  }
}

猜你喜欢

转载自see-you-again.iteye.com/blog/2257106