当前位置:网站首页>scala 基础篇
scala 基础篇
2022-08-10 14:46:00 【S_ng】
1、基本语法
o 区分大小写
o 类名:首字母要大写,如 class HelloWorld{},class
Person{},class Student{},也称大驼峰
o 方法名称:首字母小写,从第 2 个单词开启的首字段大写,如
def toString(),def getName(),即为小驼峰
o 程序文件名:保持与类名或对象名一致,区分大小写,以
".scala"来结尾。
o 主程序入口:def main(args: Array[String]) ,scala 若要独立运行
必须从 main 方法开始处理,每个 scala 强制程序入口。
2、关键字
o 以下为保留关键字,不要以关键字作为变量命名。
abstract case catch class
def do else extends
false final finally for
forSome if implicit import
lazy match new null
object override package private
protected return sealed super
this throw trait trytrue type val var while with yield - : = => <- <: <% >: # @
3、数据类型
与 Java 相似部分(皆为对象类型,scala 无原生数据类型)Byte,Short,Int,Long,Float,Double,Char,String,Boolean
4、运算符
无自增自减,其余和java相同。
5、循环
String 类。
完全与 java.lang.String 对等
边栏推荐
猜你喜欢
随机推荐
正则表达式(包含各种括号,echo,正则三剑客以及各种正则工具)
【吴恩达来信】强化学习的发展!
Mini Program-Voice broadcast function
How to code like a pro in 2022 and avoid If-Else
紫金示例
Digital Collection Platform System Development Practice
Introduction to the Internet (2)
SWIG tutorial "two"
学习MySQL 临时表
公网IP和内网IP的区别[通俗易懂]
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 7
无线网络、HTTP缓存、IPv6
pytest框架优化
Custom picker scroll selector style
PyTorch multi-machine multi-card training: DDP combat and skills
基于 Azuki 系列:NFT估值分析框架“DRIC”
E. Cross Swapping (and check out deformation/good questions)
自定义picker滚动选择器样式
Basic learning of XML
消息称原美图高管加盟蔚来手机 顶配产品或超7000元









