scala集合中添加元素

清单 (List)

A list is a linear data structure. It is a collection of elements of the same data types.

列表是线性数据结构。 它是相同数据类型的元素的集合。

Scala libraries have many functions to support the functioning of lists. Methods like isempty, head, tail, etc provide basic operations on list elements.

Scala库具有许多功能来支持列表的功能。 像isemptyheadtail等方法提供对列表元素的基本操作。

获取列表的第一个元素 (Getting first element of the list)

You can access the first element of the list in Scala using the head method form the list.

您可以使用head方法从Scala访问Scala中列表的第一个元素。

Program:

程序:

object MyObject{
def main(args:Array[String]) {
val myBikes = List("ThunderBird 350", "Yamaha R3", "BMW S1000R", "Iron 883")
println("list of my Bikes : " + myBikes)
println("First Bike from the list is: " + myBikes.head)
}
}

Output

输出量

list of my Bikes : List(ThunderBird 350, Yamaha R3, BMW S1000R, Iron 883)
First Bike from the list is: ThunderBird 350

翻译自: https://www.includehelp.com/scala/how-to-get-the-first-element-of-the-list-in-scala.aspx

scala集合中添加元素

scala集合中添加元素_如何在Scala中获得列表的第一个元素?相关推荐

  1. scala集合中添加元素_如何在Scala中将元素添加到列表中?

    scala集合中添加元素 In Scala, lists are immutable data structures in which adding new elements is not allow ...

  2. scala 字符串转换数组_如何在Scala中将字节数组转换为字符串?

    scala 字符串转换数组 Byte Array in Scala is an array of elements of a byte type. String in Scala is a colle ...

  3. scala 字符串转换数组_如何在Scala中将十六进制字符串转换为字节数组?

    scala 字符串转换数组 Hex String in Scala denotes value in hexadecimal number system i.e. base 16 number sys ...

  4. typescript中函数_如何在TypeScript中合成Canvas动画

    typescript中函数 by Changhui Xu 徐昌辉 如何在TypeScript中合成Canvas动画 (How to Compose Canvas Animations in TypeS ...

  5. javascript中索引_如何在JavaScript中找到数字在数组中所属的索引

    javascript中索引 Sorting is a very important concept when writing algorithms. There are all kinds of so ...

  6. scala中捕获异常_如何在Scala中引发异常?

    scala中捕获异常 Scala的例外 (Exceptions in Scala) Exceptions are cases or events that occur in the program a ...

  7. scala 随机生成整数_如何在Scala中以整数形式获取当前年份?

    scala 随机生成整数 In Scala programming language, there is an option for the programmer to use libraries o ...

  8. scala 字符串占位符_如何在Scala中将带有换行符的字符串转换为字符串列表?

    scala 字符串占位符 A string is a sequence of characters and it can contain multiple lines, for this, the s ...

  9. m 文件 dll matlab 中调用_如何在matlab中调用python程序

    现在python很火,很多代码都是python写的,如果你和我一样,习惯了使用matlab,还想在matlab中调用Python的代码,应该怎么办呢?其中一条思路:首先在matlab中调用系统脚本命令 ...

最新文章

  1. python定义一个变量_Python新手上车3:Python第一个程序和变量
  2. 【LibreOJ】#6299. 「CodePlus 2018 3 月赛」白金元首与克劳德斯
  3. IntelliJ - idea15.0.2 破解方法
  4. 将一个项目中已有的文档添加到另一个项目中的方法
  5. sftp get服务器无文件会抛异常,sftp 异常,有遇到的吗
  6. 睡觉时钱被转走、开房信息被叫卖、数字货币被篡改,你的安全感,还在吗?...
  7. javac -version ;java -version不一致
  8. kalilinux装到u盘上的弊端_暗黑系统安装盘高达14G!kali linux在它面前顿然失色
  9. Spring 注解中@Resource 和 Authwired 的区别
  10. 淄博联海城企业文件图纸数据信息透明加密系统
  11. Java List集合排序 Java8 List集合排序方法 Java Lambda集合排序
  12. 基于HTML的旋转立方体的实现
  13. 按键精灵 excel mysql_按键精灵常用插件介绍
  14. 音视频 FLV格式解析
  15. Android 利用adb命令 使App自动点击屏幕指定位置
  16. 优惠劵秒杀优化-分布式锁
  17. idea 代码格式化 谷歌_Google Docsmaklet格式化代码
  18. ftp文件盘服务器回档,企业网盘和FTP服务器对比
  19. 一大波折叠屏手机就要来了,你会买吗? 1
  20. 西工大非全信息汇总说明

热门文章

  1. linux grub rescue 光盘,Ubuntu9.10用安装光盘如何进入linux rescue方式?
  2. 英文数据集txt_YOLOv5在建筑工地中安全帽佩戴检测的应用(已开源+数据集)
  3. Python二级笔记(4)
  4. js禁止鼠标滑轮_js实现鼠标滑动到某个div禁止滚动
  5. 1562a检测软件_洛达1562a空间音频版评测!!!
  6. ORACLE数据库导出导入数据
  7. shell脚本:批量修改文件名(文件名中添加字符)
  8. 【载誉】致远互联荣获“2017最佳协同管理解决方案”殊荣
  9. Launch Instruments
  10. ActiveReports 报表控件官方中文新手教程 (1)-安装、激活以及产品资源