0
How to use Command line Arguments?
Class ComLineTest { Public static void main( string args[ ]) { int count,i=0; String string; count = args.length; System.out.println("Number of Arguments= " + count); while(I < count) { String = args[ i ]; i = i + 1; System.out.println(i + " : " + " java is " + string+" ! "); } } }
2 odpowiedzi
+ 4
Not feasible in SoloLearn.
You will need to test it in a PC/Laptop, or in mobile device where you have access to the terminal by use of a utility.
https://javatutoring.com/command-line-arguments-java-with-examples/
+ 1
in sololearn you can simulate it:
class ComLineTest {
public static void main( String[] args) {
if (args.length==1 && args[0].equals("-") )
args = new String[]{ "10", "20.0", "argument_03" };
System.out.println("Number of arguments: " +args.length);
for(int i=0; i< args.length; i++) {
System.out.println(" argument " +i +": " +args[i] );
}
}
}