印刷阵列斯卡拉 [英] Printing array in Scala

查看:110
本文介绍了印刷阵列斯卡拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有最基本的斯卡拉操作问题,它是让我疯了。

I am having problem with most basic Scala operation and it is making me crazy.

val a = Array(1,2,3)

println(a)   and result is [I@1e76345

println(a.toString()) and result is [I@1e76345

println(a.toString) and result is [I@1e76345

谁能告诉我如何打印数组没有写我自己的功能这样做,因为这是愚蠢的。谢谢!

Can anyone tell me how to print array without writing my own function for doing that because that is silly. Thanks!

推荐答案

mkString 将转换集合(包括阵列 )元素乘元素串重新presentations。

mkString will convert collections (including Array) element-by-element to string representations.

println(a.mkString(" "))

可能是你想要的东西。

is probably what you want.

这篇关于印刷阵列斯卡拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆