RSS

Split the given String in to Array and tune for prefix – Java

04 Mar

Hi folks,

This post is for to split the given string in to an array object and search for the prefix from each word using java.

Here is the working code to reduce your time.

public class StringSearchDemo {
/**
* @param args
*/
public static void main(String[] args) {
String icName = “Search Java ICName”;
boolean b = validateICCheck(icName);
System.out.println(b);
}

public static boolean validateICCheck(String icName) {
String[] icNameList = icName.split(“\\s”);
boolean index = false;
for (int i = 0; i < icNameList.length; i++) {
if(icNameList[i].startsWith(“IC”)){
index = icNameList[i].startsWith(“IC”);
return index;
}
}
return index;
}
}

Hope this will save you development for some extent.

Get glued to know more updates.

Have a nice day:-)

Advertisements
 
Leave a comment

Posted by on March 4, 2013 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: