how to pass Command line arguments in java -


this question has answer here:

how accept 2 digit number command line argument , print sum of digits. if 2 digit number 88 output 16. here task dont use conditional or looping statements.

just use first string passed command line adding casted integers of each digit.

public class test {     public static void main(string[] args)     {         int = integer.parseint(args[0].substring(0, 1));         int b = integer.parseint(args[0].substring(1, 2));          system.out.printf("sum: %d", + b);     } } 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -