Scala For Apache Spark|Session42|Array of Objects|ManoharPapasani|manoharpapasani.com

Опубликовано: 01 Июнь 2026
на канале: Manohar BigData Official
94
2

Array of objects:
--------------------------
class Employee {
var ename: String = null
var empID: Int = 0
var empSal: Double = 0.0


def setEmp(ename: String, empID: Int, empSal: Double): Unit = {
this.ename = ename
this.empID = empID
this.empSal = empSal
}


def getEmp(): Unit = {
println("Name " + ename)
println("empID " + empID)
println("empSal " + empSal)
}


}


//Arrays
object Test {
def main(args: Array[String]): Unit = {
//Array of employee
//step1
var e2 = new Array[Employee](5)
println(e2.length)
//code here

}


}
}


UseCase:
Print all employees whose sal is greater than 2000