Q:

Scala collections

Hi Can any one please help me on the below query.
I am working on a scala code where I have a Scala collections list 'students' as shown below.
List(
  students(Rajesh,  21, branch1, sem1), 
  students(Kamal,   25, branch2, sem2),
  students(Kavitha, 23, branch3, sem3)
)

Here students is the case class like 
case class students(name:String, age:Int, branchname:String, semname: String)

Now my requirement is to get the name for a particular branch. How can i get that. 
I can convert the Scala list students into dataframe using .toDF() and write the where conditions to read the appropriate row and get the value.
But since the data is very small for me in this case so I want to use purely scala collections List.
Can anyone please help on the same. 

A:

your question does not mention why spark is required, you could do this all very easily as follows, assuming  your case class is defines the same
case class students(name: String, age: Int, branch: String, sem: String)

val listStudents = List(students("Rajesh",21,"branch1","sem1"),
    students("Kamal",25,"branch2","sem2"),students("Kavitha",23,"branch3","sem3"))

val filteredNames = listStudents.filter(_.branch == "branch2").map(_.name)

