Question
Task #4: Command Line Arguments Part A. Create a java class/file called CommandLines.java with a mainmethod. In the main method write a loop that traverses
Task #4: Command Line Arguments
Part A.
Create a java class/file called CommandLines.java with a mainmethod.
In the main method write a loop that traverses through the argsarray and prints the contents of each element in the followingformat:
args[0]: hello
args[1]: how
Save this java file in the User folder in your C drive.
Open the command prompt window and compile the program bytyping:
javacCommandLine.java
NOTE: MAKE SURE YOUR ARE IN THE CORRECT DIRECTORY (CHECK YOURPATH)
After a successful compilation of the program, run the followingcommand by writing the arguments-
java CommandLine argument-list
For example – java CommandLine My favorite color is Purple
Press Enter and you will get the desired output.
After performing the above steps, we will get the followingoutput:
args[0]: My
args[1]: favorite
args[2]: color
args[3]: is
args[4]: purple
part B.
Traverse through your array and print the names that contain thesubstring "ma" and whose length is less than 5
Test case:
kim andy mary jose khoi omar maryam henryemma
part C
Traverse through your array and calculate the average of all thenumbers less than 7
Test case:
2 11 10 4 5 7 14 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started