Check if String starts with a given word

package com.string;

public class StringStartWithWord {

	public static void main(String args[]) {
		String str = "HiHello";
		String str1 = "Hello";

		/*
		 * Now we will use inbuild method to check if given string start with Hi
		 * or not Note: This checck is case sensitive
		 */
		System.out.println("Given String starts with "Hi"(true/false)?"
				+ str.startsWith("Hi"));
		System.out.println("Given String starts with "Hi"(true/false)?"
				+ str1.startsWith("Hi"));
	}
}

 

By | 2012-04-28T13:05:34+00:00 April 28th, 2012|Code Base|0 Comments

About the Author:

Leave A Comment