Pages

Get word from a sentence in java

**************************************************
COMPLETE SOURCE CODE FOR : GetWordFromASentence.java
**************************************************


public class GetWordFromASentence
{
public static void main(String[]args)
{
//This source code will show you how to get word Hello from sentence Hello World

//You can use method substring(index_for_first_letter_for_word,index_for_last_letter_plus_one)

//Index start with 0

//Blank space also count.In this case, space between Hello and world take 5 for it's index

String a="Hello world!!";
String b=a.substring(0,5);

System.out.println(b);
}
}


**************************************************
JUST COMPILE AND EXECUTE IT
**************************************************
Related Posts Plugin for WordPress, Blogger...