Program to convert Java list of Strings to an Indexed Sequence in Scala Last Updated : 29 Dec, 2019 Comments Improve Suggest changes Like Article Like Report A java list of Strings can be converted to an Indexed Sequence in Scala by utilizing toIndexedSeq 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 // Scala program to convert Java list // to an Indexed Sequence 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 Strings in Java val list = new java.util.ArrayList[String]() // Adding Strings to the list list.add("geeks") list.add("for") list.add("geeks") // Converting list to an Indexed Sequence val ind = list.toIndexedSeq // Displays Indexed Sequence println(ind) } } Output: Vector(geeks, for, geeks) Therefore, an indexed sequence is returned. Example:2# Scala // Scala program to convert Java list // to an Indexed Sequence 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 Strings in Java val list = new java.util.ArrayList[String]() // Adding Strings to the list list.add("I") list.add("am an") list.add("author") // Converting list to an Indexed Sequence val ind = list.toIndexedSeq // Displays Indexed Sequence println(ind) } } Output: Vector(I, am an, author) Here, the stated list is not in proper order so the resultant output is also not in proper order. That is, the strings with more number of words are not displayed in the last, they are returned as stated in the list. Comment More infoAdvertise with us Next Article Program to convert Java list of Strings to an Indexed Sequence in Scala nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Scala Programming Language Scala is a general-purpose, high-level, multi-paradigm programming language. It is a pure object-oriented programming language which also provides support to the functional programming approach. Scala programs can convert to bytecodes and can run on the JVM (Java Virtual Machine). Scala stands for S 3 min read Learn Free Programming Languages In this rapidly growing world, programming languages are also rapidly expanding, and it is very hard to determine the exact number of programming languages. Programming languages are an essential part of software development because they create a communication bridge between humans and computers. No 9 min read Scala Tutorial â Learn Scala with Step By Step Guide Scala is a general-purpose programming language that combines both object-oriented and functional programming. Designed for scalability and flexibility, it allows developers to write concise and maintainable code for everything from small scripts to large enterprise systems. First released in June 2 15+ min read Introduction to Scala Scala is a general-purpose, high-level, multi-paradigm programming language. It is a pure object-oriented programming language which also provides the support to the functional programming approach. There is no concept of primitive data as everything is an object in Scala. It is designed to express 7 min read Scala vs Java Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, etc. Java applications are compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. Scala is a general-purpose, high-level, multi-paradigm program 2 min read Scala | flatMap Method In Scala, flatMap() method is identical to the map() method, but the only difference is that in flatMap the inner grouping of an item is removed and a sequence is generated. It can be defined as a blend of map method and flatten method. The output obtained by running the map method followed by the f 4 min read For Loop in Scala In Scala, for loop is also known as for-comprehensions. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The loop enables us to perform n number of steps together in one line. Syntax: for(w <- range){ // Code.. } Here, w is 6 min read Scala Console | println, printf and readLine Console implements functions for displaying the stated values on the terminal i.e, with print, println, and printf we can post to the display. It is also utilized in reading values from the Console with the function from scala.io.StdIn. It is even helpful in constructing interactive programs. Let's 2 min read Hello World Program : First program while learning Programming In this article, I'll show you how to create your first Hello World computer program in various languages. Along with the program, comments are provided to help you better understand the terms and keywords used in theLearning program. Programming can be simplified as follows: Write the program in a 6 min read How to Install Scala with VSCode? Scala is a multi-paradigm, general-purpose, high-level programming language. It is an object-oriented programming language that also supports functional programming and it is easy to use. Its applications can be converted to bytecodes and executed on the Java Virtual Machine (JVM) (Java Virtual Mach 2 min read Like