Pageviews

Sunday 16 June 2013

startsWith() and endsWith() in Java

by Unknown  |  in Strings at  Sunday, June 16, 2013

startsWith():This function returns result in Boolean expression. If the given value matches with the value specified as argument then the result is true otherwise false.

Syntax:Stringname.startsWith(Value);

 endsWith():This function also returns result in Boolean.If the given value  matches with the value specified as argument then the result is true otherwise false.

Syntax:Stringname.endsWith(Value);

WAP in Java to show the use of startsWith() and endsWith() String functions in Java:

class dony{
public static void main(String args[])
{
String str=new String("Hello to all");
System.out.println(str.startsWith("to"));
System.out.println(str.endsWith("all"));
System.out.println(str);
}
}

The output is:

Strings

0 comments:

Proudly Powered by Blogger.