class ApplyTest{

  //一定要写(),不加括号就报错。
  def apply() = println("Into Spark!")
  def havaAtry(){
    println("have a try!")
  }
}

object ApplyTest{

  //一定要写(),不加括号就报错。
  def apply() = new ApplyTest
}

//调用时:

val test = ApplyTest()

test.haveAtry()

//类名+(),相当于调用class的Apply()方法。

println(test())

//类名后面加括号,相当于调用伴生对象的apply方法

最新文章

  1. Rethink your own
  2. 《BI项目笔记》创建时间维度(1)
  3. Lua.LearningLua.7-userdata
  4. 更改printk打印级别
  5. Linux进程控制(一)
  6. IIS Express start introduction and applicationHost modification
  7. poj 1915 http://poj.org/problem?id=1915
  8. SQL Server 对象
  9. Catalog和Schema
  10. 你想建设一个能承受500万PV/每天的网站吗?如果计算呢?(转)
  11. Spring MVC返回的json如何去除根节点名称
  12. javascript的关键所在---作用域链
  13. python 函数递归
  14. 统计numpy数组中最频繁出现的值
  15. 15树莓派安装图形界面截图工具Shutter
  16. 上下文调用(call , apply , bind)
  17. vue.js computed,watch的区别
  18. Python hasattr,getattr,setattr,delattr
  19. 一个第三方Dart库导致的编译错误!
  20. Windows下RabbitMQ安装及配置

热门文章

  1. 使用axis2访问webservice(webserivice基于.net平台实现)
  2. 鸟哥的LINUX私房菜基础篇第三版 阅读笔记 三 Linux磁盘与文件系统管理
  3. 批处理安装nodejs
  4. php的sendmail发件人邮箱设定
  5. oracle-计算工作日
  6. 用Bottle开发web程序(一)
  7. dll导出命名空间下的c风格函数陷阱
  8. C语言之switch
  9. Android中使用开源框架PagerSlidingTabStrip实现导航标题
  10. java中的instanceof