Q:

Java program to extract words from a given sentence

0

Java program to extract words from a given sentence

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Extract words from a string in java

class ExtractWordFromSentence
{
	public static void main(String args[])
	{
		String str = "My Name Is Preeti Jain";
		String [] words = str.split(" ", 5);

		for (String word : words)
			System.out.println(word);
	}
}

Output

D:\Java Articles>java ExtractWordFromSentence
My
Name
Is
Preeti
Jain

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now