From the course: Java 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Passing arguments to a console application - Java Tutorial
From the course: Java 8 Essential Training
Passing arguments to a console application
- When you run a java class from the console or a command prompt, the run time looks for the main method, and you can pass values, known as arguments, into that main method as strings. For this demonstration, I'll use the Main.java file in the Arguments folder under the Exercise folder. You can open this, again, with any text editor. And I'll open it, as I did before, with Notepad. When you run from the console, you can pass string values in, and they'll show up in this array of strings. You can address each item in the array individually using the name of the array, a pair of brackets, and an index or a numeric value. So, for example, if I wanted to output a value, which is the first argument passed in on the command line, I would once again use System.out.println and then I would use this expression: args[0]. The first item in the array has an index value of zero. Java always uses zero based array indexing. I'll save that change, and then, once again, I'll go to a command prompt…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Hello World5m 44s
-
(Locked)
Passing arguments to a console application2m 53s
-
(Locked)
Organizing Java classes in packages4m 12s
-
Creating a Java project in IntelliJ IDEA7m 28s
-
(Locked)
Taking a tour of IntelliJ IDEA3m 35s
-
(Locked)
Creating a Java project in BlueJ4m 43s
-
(Locked)
Using the Java API documentation3m 44s
-
(Locked)
-
-
-
-
-
-
-
-
-
-