Q:

How can we print this output?

String x = "1 -7 2";
String y = "-2 2 1";

Output:
1,-2
-7,2
2,1

We'll use x's first number which is negative or positive, y's first number ...

A:

This should do:
String[] splitX = x.split(" ");
String[] splitY = y.split(" ");

System.out.println(splitX[0]+","+splitY[0]);
System.out.println(splitX[1]+","+splitY[1]);
System.out.println(splitX[2]+","+splitY[2]);

