七:Array/List实操比较-Map需要留意地方

  • 目录:
  • 1、数组实操
  • 2、List实操:
  • 3、Array和List区别:
  • 4、Map实操:
  • 5、其他列表

1、数组实操

1.1、定长数组

//定义
scala>  val a =new Array[Boolean](5)
a: Array[Boolean] = Array(false, false, false, false, false)

scala> val a =new Array[String](5)
a: Array[String] = Array(null, null, null, null, null)

scala> val a =new Array[Int](5)
a: Array[Int] = Array(0, 0, 0, 0, 0)
//写
scala> a(1)=10
scala> a
res13: Array[Int] = Array(0, 10, 0, 0, 0)
/读
scala> a(1)
res14: Int = 10
// 数组可以不用new,直接引用apply方法创建
scala> val b = Array(1,2)
b: Array[Int] = Array(1, 2)


数组相关:
数组操作中的常用算法:max/min/sum/mkstring(",")

1.2变成数组

insert/toArray/

import scala.collection.mutable.ArrayBuffer
scala> val c = ArrayBuffer[Int]()
c: scala.collect
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
npm WARN deprecated source-map[email protected]: See https://github.com/lydell/source-map-url#deprecated npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility npm WARN deprecated [email protected]: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated source-map[email protected]: See https://github.com/lydell/source-map-resolve#deprecated npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]: Use your platform's native performance.now() and performance.timeOrigin. npm WARN deprecated [email protected]: This project has been renamed to @pawelgalazka/cli-args. Install using @pawelgalazka/cli-args instead npm WARN deprecated [email protected]: This project has been renamed to @pawelgalazka/cli . Install using @pawelgalazka/cli instead npm WARN deprecated @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information. npm WARN tarball tarball data for @jest/types@http://10.129.3.105:8081/repository/npm-all/@jest/types/-/types-27.5.1.tgz (sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==) seems to be corrupted. Trying again. npm WARN deprecated [email protected]: This project has been renamed to 'tasksfile'. Install using 'npm install tasksfile' instead. npm WARN tarball tarball data for @jest/console@http://10.129.3.105:8081/repository/npm-all/@jest/console/-/console-27.5.1.tgz (sha512-kZ/tNpS3NXn0mlXXXPNuDZnb4c0oZ20r4K5eemM2k30ZC3G0T02nXUvyhf5YdbXWHPEJLc9qGLxEZ216MdL+Zg==) seems to be corrupted. Trying again. npm WARN tarball tarball data for @jest/test-result@http://10.129.3.105:8081/repository/npm-all/@jest/test-result/-/test-result-27.5.1.tgz (sha512-EW35l2RYFUcUQxFJz5Cv5MTOxlJIQs4I7gxzi2zVU7PJhOwfYq1MdC5nhSmYjX1gmMmLPvB3sIaC+BkcHRBfag==) seems to be corrupted. Trying again. npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x. npm WARN tarball tarball data for @jest/types@http://10.129.3.105:8081/repository/npm-all/@jest/types/-/types-27.5.1.tgz (sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==) seems to be corrupted. Trying again. npm WARN tarball tarball data for @jest/console@http://10.129.3.105:8081/repository/npm-all/@jest/console/-/console-27.5.1.tgz (sha512-kZ/tNpS3NXn0mlXXXPNuDZnb4c0oZ20r4K5eemM2k30ZC3G0T02nXUvyhf5YdbXWHPEJLc9qGLxEZ216MdL+Zg==) seems to be corrupted. Trying again. npm WARN tarball tarball data for @jest/test-result@http://10.129.3.105:8081/repository/npm-all/@jest/test-result/-/test-result-27.5.1.tgz (sha512-EW35l2RYFUcUQxFJz5Cv5MTOxlJIQs4I7gxzi2zVU7PJhOwfYq1MdC5nhSmYjX1gmMmLPvB3sIaC+BkcHRBfag==) seems to be corrupted. Trying again.
07-22

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值