package main.scala
import scala.collection.mutable.ArrayBuffer
object Arr {
var arr=new Array [String ](3 )
var arr1=Array .range(10 ,20 )
var arr2=Array (1 ,2 ,3 ,4 ,5 ,6 )
var arr3=ArrayBuffer [Int](elems = 1 ,2 ,3 ,4 ,5 )
var arr4=new Array [String ](3 )
var arr5=new Array [ArrayBuffer [Int]](5 )
var arr6=new Array [Array [Int]](5 )
var arr7=Array .ofDim[Int](n1=3 ,n2=4 )
def main(args: Array [String ]): Unit = {
print_arr()
print_arr3()
print_arr6()
Array_Method()
}
def print_arr(): Unit ={
for (s <- 0 to 2 )
{
arr(s)="Str" +String .valueOf(s)
println(arr(s))
}
}
def print_arr3(): Unit ={
for (i <- 0 to arr3.length-1 )
{
println(arr3(i))
}
for (j <- 0 until arr3.length)
{
print(arr3(j)+" " )
}
for (k <- arr3)
{
print(k+" " )
}
println(arr3.mkString("(" ,"," ,")" ))
}
def print_arr6(): Unit ={
for (i <- 0 until arr6.length)
{
arr6(i)=new Array [Int](5 )
for (j <- 0 until arr6(i).length)
{
arr6(i)(j)=i*j
print(arr6(i)(j)+"*" )
}
println()
}
}
def Array_Method(): Unit ={
println(arr3.sum)
println(arr3 += 1 )
println(arr3+=(1 ,2 ,3 ) )
println(arr3++=Array (5 ,6 ,7 ))
arr3.insert(2 ,10 )
arr3.insert(3 ,11 ,12 ,13 )
println(arr3)
arr3.remove(0 )
arr3.remove(0 ,2 )
println(arr3.reverse)
}
}