- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
A Scala Tutorial
for Java programmers
Version 1.3
March 15, 2009
Michel Schinz, Philipp
Haller
Translated to Simplified Chinese by Bearice
PRO G R A M M I N G ME T H O D S L A B O R ATO RY
EPFL SW I T Z E R L A N D
2
1 Introduction简介
This document gives a quick introduction to the Scala language and compiler. It is intended for people who already have some programming experience and want an overview of what they can do with Scala. A basic knowledge of object-oriented programming, especially in Java, is assumed.
本文仅在对Scala语言和其编译器进行简要介绍。本文的目的读者是那些已经具有一定编程经验,而想尝试一下Scala语言的人们。要阅读本文,你应当具有基础的面向对象编程的概念,尤其是Java语言的。
2 A first example 第一个例子
As a first example, we will use the standard Hello worldprogram. It is not very fasci- nating but makes it easy to demonstrate the use of the Scala tools without knowing too much about the language. Here is how it looks:
作为学习Scala的第一部,我们将首先写一个标准的HelloWorld,这个虽然不是很有趣,但是它可以是你对Scala有一个最直观的认识而不需要太多关于这个语言的知识。我们的Hello world看起来像这样:
objectHelloWorld {
defmain(args: Array[String]) {
println(”Hello, world!”)
}
}
The structure of this program should be familiar to Java programmers: it consists of one method called main which takes the command line arguments, an array of strings, as parameter; the body of this method consists of a single call to the pre- defined method println with the friendly greeting as argument. The main method does not return a value (it is a procedure method). Therefore, it is not necessary to declare a return type.
程序的结构对Java程序员来说可能很令人怀念:它由一个main函数来接受命令行参数,也就是一个String数组。这个函数的唯一一行代码把我们的问候语传递给了一个叫println的预定义函数。main函数不返回值(所以它是一个procedure method)。所以,也不需要声明返回类型。
What is less familiar to Java programmers is the objectdeclaration containing the main method. Such a declaration introduces what is commonly known as a single- ton object, that is a class with a single instance. The declaration above thus declares both a class called HelloWorld and an instance of that class, also called HelloWorld.
您可能关注的文档
最近下载
- 上海凯泉选型样本-第五代数字集成变频供水设备.pdf
- 2025年山西林业职业技术学院单招职业倾向性测试题库(实用).docx VIP
- 党员一对一谈心谈话记录.docx VIP
- 安徽省合肥市2023-2024学年六年级上学期语文期末试卷(含答案)2.pdf VIP
- 员工个人年终总结7篇.docx VIP
- 场景搭配培训课件.pptx VIP
- 《特种设备安全法》解读及特种设备监督管理.pptx VIP
- CMW500操作快速入门:Bluetooth信令测试.pdf VIP
- 蓝色绿色商务科技风特种设备安全技术培训安全培训培训特种设备特种设备知识培训.pptx VIP
- 佛马特fermator门机VVVF-4+门机调试说明书.pdf
原创力文档


文档评论(0)