From the course: Java 8+ Essential Training: Syntax and Structure
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Pass arguments to a console application - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
Pass arguments to a console application
- [Instructor] The main method of a Java class accepts an array of strings. These strings are provided by passing in values or parameters from the command line, and I'll show you how to do this using a project that I've already created. From the welcome screen, I'll choose Open. Then I'll go to my Desktop where I've placed my Exercise Files. On Windows, I can press Control + D, and on Mac, press Command + D. Then I'll drill down into my Exercise Files to chapter two, 02_07, and I'll open the project PassArgs. This is a beginning Java class with an empty main method. When you receive these arguments, they're received as an array of strings. An array is an ordered set of values. Here's some pretty standard code for looping through those values. I'll place the cursor inside the main method, then I'll type the expression foreach, all one word, lowercase. Then I'll press Tab, and that expands to some mysterious syntax. Now, just follow along with the code, and I'll explain what it's doing…
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
-
-
-
-
Install Java on Windows2m 17s
-
Add Java to the system PATH on Windows2m 41s
-
Install Java on OS X2m 59s
-
Test simple Java code in JShell4m 49s
-
Install and configure IntelliJ IDEA3m 45s
-
Create a project in IntelliJ IDEA6m 10s
-
Pass arguments to a console application5m
-
Take a tour of IntelliJ IDEA3m 56s
-
Use the Java API documentation4m 24s
-
-
-
-
-