blademainer / blademainer.github.com

My blog of http://xiongyingqi.com. Source is https://github.com/blademainer/blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scala根据Class获取单例(孤立)对象 | Blademainer

blademainer opened this issue · comments

https://blog.xiongyingqi.com/2015/10/30/scala-object-reflect-get/

开发中遇到的问题在scala开发过程中,有需要使用Class获取scala单例(孤立)对象的需求,但是直接使用Class.newInstance()是无法获取单例对象的。发现google之后,在一篇博客:http://blog.csdn.net/zhangjg_blog/article/details/23376465 其中有一个例子:1234object Test {trueval