Suppose you are provided with 2 strings to your program. Your task is to join the strings together so you get a single string with a space between the 2 original strings. This is a common case is coding and you will need to create your output by joining the inputs and adding the space in the middle.

# Input from the command line
import sys
string1 = sys.argv[1]
string2 = sys.argv[2]

Respuesta :

ijeggs

Answer:

public class TestImport{

   public static void main(String[] args) {

       String string1 = args[1];

       String string2 = args[2];

       System.out.println(string1 +" " +string2);

   }

}

Explanation:

The solution here is to use string concatenation as has been used in this statement System.out.println(string1 +" " +string2);

When this code is run from the command line and passed atleast three command line arguments for index 0,1,2 respectively, the print statment will return the second string (that is index1) and the third argument(that is index2) with a space in-between the two string.