public class Main { public static void main(String args[]) throws Exception { String[] words = " ".split(" "); String firstWord = words[0]; System.out.println(firstWord); } } /* Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Main.main(Main.java:5) */