Question: JAVA How can I use the phrase.split method to separate phrases into words from command line input by user public static void main(string[] args) {

public static void main(string[] args) \{ if (isvalidPhrase(args)) \{ getWords (args); \} else \{ System.out.println("Invalid Phrase"); \} \} public static boolean isValidPhrase(string[] phrase) \{ for (String arg : phrase) for (char c : arg.tocharArray()) if (!Character.isLetter (c)) i return false; \} // if not letter \} /l for tochararray \} /l for each item in array return true; 3 * Separate words from command line arguments * ereturn words */ public staitc string[] getWords(String[] phrase) \{ String[] getWords = phrase.split(" ") ; return getWords; \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
