user3858193
user3858193

Reputation: 1518

Scala split function error

Can you please correct my code.I am trying to print x22 by spliting x11.

object ScalaString {

  def main(args: Array[String]): Unit = {
    var x =" Hello world"
    x.filter(_!='l').foreach(println)
    //for(c <- x) println(c)
   println(x.stripPrefix(" ").drop(2).take(2).capitalize)
    **var x11=" hello|world|india"
    var x22=( x11.split("|").map(_.trim()))
    println(x22.toString())**

  }

}

output:
w
o
r
d
Ll
**[Ljava.lang.String;@56431753**

Upvotes: 1

Views: 251

Answers (1)

lmm
lmm

Reputation: 17431

That's what the toString of an Array looks like. Try x22.mkString instead.

Upvotes: 5

Related Questions