Program to convert Java list of Integer to an Iterable in Scala Last Updated : 31 Dec, 2019 Comments Improve Suggest changes Like Article Like Report A java list of Integer can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, we 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 // 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 Integer in Java val list = new java.util.ArrayList[Int]() // Adding Integer to the list list.add(8) list.add(9) list.add(10) // Converting list to an Iterable val iterab= list.toIterable // Displays output println(iterab) } } Output: Buffer(8, 9, 10) Therefore, a buffer is returned and the elements are present in the order of the stated list and also duplicate elements are not eliminated here. Example:2# Scala // 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 Integer in Java val list = new java.util.ArrayList[Int]() // Adding Integer to the list list.add(3) list.add(2) list.add(1) // Converting list to an Iterable val iterab= list.toIterable // Displays output println(iterab) } } Output: Buffer(3, 2, 1) Here, the stated list is not in proper order so the resultant buffer is also not in proper order. Comment More infoAdvertise with us Next Article Program to convert Java list of Integer to an Iterable in Scala nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Program to convert Java set of integers to an Iterable in Scala A java set of integers 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 detai 2 min read Program to convert Java list of floats to an Iterable in Scala A java list of floats can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, we 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 2 min read Program to convert Java list of doubles to an Iterable in Scala 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 detai 2 min read Program to convert Java list of bytes to an Iterable in Scala A java list of bytes can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, we 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. 2 min read Program to convert Java list of Shorts to an Iterable in Scala A java list of Shorts can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, we 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 2 min read Program to convert Java list to an iterator in Scala A java list can be converted to an iterator in Scala by utilizing toIterator method of Java in Scala. Here, we 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: 3 min read Program to convert Java list of Strings to an Iterable in Scala A java list of Strings 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 detai 2 min read Program to convert Java list of characters to an Iterable in Scala A java list of characters can be converted to an Iterable in Scala by utilizing toIterable method of Java in Scala. Here, we 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 det 2 min read Program to convert Java list of integers to an Indexed Sequence in Scala A java list can be converted to an Indexed Sequence in Scala by utilizing toIndexedSeq method of Java in Scala. Here, we 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 2 min read Program to convert Java set of doubles to an Iterable in Scala A java set 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 detail 2 min read Like