Program to convert Java list of doubles to an Iterable in Scala Last Updated : 14 Jan, 2020 Improve Improve Like Article Like Save Share Report A java list of doubles can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, you need to import Scala’s JavaConversions object in order to make this conversions work else an error will occur. Now, lets see some examples and then discuss how it works in details. Example:1# // Scala program to convert Java list // to an Iterable in Scala // Importing Scala's JavaConversions object import scala.collection.JavaConversions._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating list of doubles in Java val list = new java.util.ArrayList[Double]() // Adding doubles to the list list.add(8.1) list.add(9.1) list.add(10.1) // Converting list to an Iterable val iterab= list.toIterable // Displays output println(iterab) } } Output: Buffer(8.1, 9.1, 10.1) Example:2# // Scala program to convert Java list // to an Iterable in Scala // Importing Scala's JavaConversions object import scala.collection.JavaConversions._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating list of doubles in Java val list = new java.util.ArrayList[Double]() // Adding doubles to the list list.add(3.3) list.add(2.4) list.add(1.1) // Converting list to an Iterable val iterab= list.toIterable // Displays output println(iterab) } } Output: Buffer(3.3, 2.4, 1.1) Like Article Suggest improvement Previous Program to convert Java list of Shorts to Traversable in Scala Next Program to convert Java Set of characters to Sequence in Scala Share your thoughts in the comments Add Your Comment Please Login to comment...