Created
July 7, 2020 20:40
-
-
Save ruddha2001/5af60b87c3bf2979e2d500a04da67cde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SumOfNumbers - To find the sum of all the numbers passed as command line | |
* input | |
*/ | |
public class SumOfNumbers { | |
public static void main(String[] args) { | |
int len = args.length; // Length of the array args | |
int sum = 0; // Variable to hold our result | |
for (int i = 0; i < len; i++) | |
sum += Integer.parseInt(args[i]); // Parsing each string item to Integer and add to sum | |
System.out.print(sum); // Printing the result to standard console | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment