文字列を文字列配列に分割しようとしていますが、文字列を分割すると、分割前の最初の部分のみが [0] スロットの配列にあり、[1] 以降には何もありません。これも spliced[1] を出力しようとすると Java 例外エラーを返します。
import java.util.Scanner;
public class splittingString
{
static String s;
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the length and units with a space between them");
s = input.next();
String[] spliced = s.split("\\s+");
System.out.println("You have entered " + spliced[0] + " in the units of" + spliced[1]);
}
}