//store input string in an array with an length unknown Scanner scanner = new Scanner(System.in); String[] string = scanner.nextLine().split(" ");