I'm trying to implement Bubble Sort in Scala.
This is my implementation:
object Example {
def bubbleSort(arr:Array[Int])={
var temp=0
for(i<- 1 until arr.length-1 ; j<- 1 until (arr.length-1-i)){
if(arr(j-1)>arr(j)) {
temp=arr(j-1)
arr(j-1)=arr(j)
arr(j)=temp
}
}
arr
}
def main(args: Array[String]): Unit = {
var x = bubbleSort(Array(3, 60, 35, 2, 45, 320, 5))
println(x)
}
}
The problem is that the following output is printed:
[I@68be2bc2
What's the problem?