[SOLVED] Command Line Arguments and ParseInt
Hi. This is what Im working on.
1. Write a program Average.java that just prints the strings that it is given at the command line, one per line. If nothing
is given at the command line, print "No arguments".
2. Modify your program so that it assumes the arguments given at the command line are integers. If there are no
arguments, print a message. If there is at least one argument, compute and print the average of the arguments. Note
that you will need to use the parseInt method of the Integer class to extract integer values from the strings that are
passed in. If any non-integer values are passed in, your program will produce an error, which is unavoidable at this
Can anyone help explain how to do it and how to convert String to integer using parseint? If possilbe, provide an example? I havent learned
Here's what I have so far.
public class Command
public static void main(String args)
//How to print "No arguments" if nothing is entered? Do I use if else and .equals method? How do I use parseInt?
This is all I know about command line arguments:
public class NameTag
public static void main (String args)
System.out.println (" " + args);
System.out.println ("My name is " + args);
THANKS FOR THE HELP!!