Pages

Determine String start with specified word

Complete source code below will show you, how to determine whether a String start with specified word or not.

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


public class DetermineStringStartWithWord
{
public static void main(String[]args)
{
//First String
//You can try change it
String a="Hello";

//Second String
//You can try change it
String b="Hel";

//Determine if first String start with second String or not
//If yes, program will print YES, otherwise it will print NO
if(a.startsWith(b))
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
}
}


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