package com.test.scala.test /**
* 单例对象,这种对象不能提供构造函数
*/
object SingleObject { private var lastnumber=0; def newUnqiueNumber={lastnumber+=1;lastnumber} def main(args: Array[String]): Unit = {
println(newUnqiueNumber)
println(newUnqiueNumber)
println(newUnqiueNumber)
println(newUnqiueNumber)
println(newUnqiueNumber)
println(newUnqiueNumber)
println(SingleObject.lastnumber)
newUnqiueNumber
println(SingleObject.lastnumber)
}
}