how to pass Command line arguments in java -
this question has answer here:
- java command line arguments 9 answers
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
Post a Comment