Command Line Argument in Scala Last Updated : 26 May, 2021 Comments Improve Suggest changes Like Article Like Report The arguments which are passed by the user or programmer to the main() method are termed as Command-Line Arguments. main() method is the entry point of execution of a program. main() method accepts an array of strings. runtime. But it never accepts parameters from any other method in the program. Syntax: def main(args: Array[String]) For accessing our Scala command-line arguments using the args array, which is made available to us implicitly when we extend App. Here is an example.Example 1: Print all given objects Scala // Scala Program on command line argument object CMDExample { // Main method def main(args: Array[String]) { println("Scala Command Line Argument Example"); // You pass any thing at runtime // that will be print on the console for(arg<-args) { println(arg); } } } To Compile and execute the above program on terminal follow below commands : First save program CMDExample.scala then open CMD/Terminal and go on that directory where you save your scala program. Compile: scalac CMDExample.scala Execute: scala CMDExample Welcome To GeeksforGeeks! Output: Scala Command Line Argument Example Welcome To GeeksforGeeks! Example 2: Print some object which is given at runtime Scala // Scala Program on command line argument object CMDExample { // Main method def main(args: Array[String]) { println("Scala Command Line Argument Example"); // You pass any thing at runtime // that will be print on the console println(args(0)); println(args(2)); } } To Compile and execute the above program on terminal follow below commands : Compile: scalac CMDExample.scala Execute: scala CMDExample 1 Welcome To GeeksforGeeks! 2 Output: Scala Command Line Argument Example 1 To Note:If given index not present in array then you find this error Comment More infoAdvertise with us Next Article Command Line Argument in Scala 29AjayKumar Follow Improve Article Tags : Scala Scala Scala-Basics Similar Reads Scala | Named Arguments In Scala when arguments passes through the function with a named parameters, we can label the arguments with their parameter names.These named arguments are cross matched with the named parameters of function. In normal scenario Unnamed Parameters uses Parameter Positions to make Function or Constru 3 min read 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 Getting Started with Scala and sbt on the Command Line Scala is a potent general-purpose programming language with structured query data types that supports both operational and object-oriented programming. Many of Scala's design decisions are intended to be brief and try to address Java's critics. In this article learn how to create a Scala project fro 2 min read Interesting fact about Scala Scala(pronounced as "skah-lah") is general-purpose programming language designed by Martin Odersky. The design of Scala started in 2001 at EPFL, Lausanne, Switzerland. Scala was released publicly in 2004 on Java platform. Scala is designed to be concise and addresses criticisms of Java. Scala source 3 min read Scala Long >=(x: Int) method In Scala, Long is a 64-bit signed integer, which is equivalent to Java's long primitive type. The >=(x: Int) method is utilized to return true if this value is greater than or equal to x, false otherwise. Method Definition - def >=(x: Int): Boolean Returns - Returns true if this value is great 1 min read Like