var l = List(34, 32, 132, 352) // Scala List l.foreach{i => val data:DataFrame = DataContainer.getDataFrame(i) // get DataFrame val x = new MyClass(data) // initialize MyClass with new Object x.setSettings(...) x.calcSomething() x.saveResults() // writes the Results into another Dataframe that is saved to HDFS }