热线电话:13121318867

登录
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.0000
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子