Забих тотално.
Как да се оттърва от паразитната запетя накрая:
import java.util.Scanner;
public class StrangeOrder {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] input = scanner.nextLine().split(",");
int[] arr = new int[input.length];
for (int i = 0; i < input.length; i++) {
arr[i] = Integer.parseInt(input[i]);
}
int[] negativeArr = new int[arr.length];
int[] positiveArr = new int[arr.length];
int[] zeroArr = new int[arr.length];
String negative = "";
String positive = "";
String zero = "";
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
negativeArr[i] = arr[i];
negative = negative + negativeArr[i] + ",";
} else if (arr[i] > 0) {
positiveArr[i] = arr[i];
positive = positive + positiveArr[i] + ",";
} else if (arr[i] == 0) {
zeroArr[i] = arr[i];
zero = zero + zeroArr[i] + ",";
}
}
System.out.println(negative + zero + positive);
}
}