2020-02-21
阅读量:
984
scala中object类实例化的对象是单例对象
object ApplyApp{
def main(args: Array[String]): Unit = {
for(i <- 1 to 10){
ApplyTest.incre
print(ApplyTest.count)
}
}
}
object ApplyTest{
var count = 0
def incre = {
count = count + 1
}
}
结果是10 证明object定义的类实例化出来的单例对象






评论(0)


暂无数据
推荐帖子
0条评论
1条评论
0条评论