Advertisement
public boolean endsWith(String st)
// endsWith() method of String.
class StringEndsWith
{
public static void main(String[] ar)
{
String str1= new String("A Blue Moon");
System.out.println("String is " + str1);
boolean boo1 = str1.endsWith("Moon");
System.out.println("Does "+ str1 + " ends with Moon ? "+ boo1);
boolean boo2 = str1.endsWith("on");
System.out.println("Does "+ str1 + " ends with on ? "+ boo2);
boolean boo3 = str1.endsWith("A Blue");
System.out.println("Does "+ str1 + " ends with A Blue ? "+ boo3);
}
}
String is A Blue Moon
Does A Blue Moon ends with Moon ? true
Does A Blue Moon ends with on ? true
Does A Blue Moon ends with A Blue ? false
// endsWith() method of String.
class StringStartsWith
{
public static void main(String[] ar)
{
String str1= new String("A Mango Tree");
System.out.println("String is " + str1);
boolean boo1 = str1.startsWith("Tree");
System.out.println("Does "+ str1 + " ends with Tree ? "+ boo1);
boolean boo2 = str1.startsWith("tree");
System.out.println("Does "+ str1 + " ends with tree ? "+ boo2);
boolean boo3 = str1.startsWith("mango Tree");
System.out.println("Does "+ str1 + " ends with mango Tree ? "+ boo3);
}
}
String is A Mango Tree
Does A Mango Tree ends with Tree ? true
Does A Mango Tree ends with tree ? false
Does A Mango Tree ends with mango Tree ? false
Advertisement
// endsWith() method of String.
class StringEndsWith2
{
public static void main(String[] ar)
{
String str1= new String("Kepler 452b");
System.out.println("String is " + str1);
boolean boo1 = str1.endsWith("Kepler");
System.out.println("Does String "+ str1 + " ends with Kepler ? "+ boo1);
boolean boo1 = str1.endsWith("452");
System.out.println("Does String "+ str1 + " ends with 452? "+ boo1);
boolean boo2 = str1.endsWith("52b");
System.out.println("Does String "+ str1 + " ends with 52b ? "+ boo2);
boolean boo3 = str1.endsWith("Kepler 452b");
System.out.println("Does String "+ str1 + " ends with Kepler 452b ? "+ boo3);
}
}
String is Kepler 452b
Does String Kepler 452b ends with Kepler ? false
Does String Kepler 452b ends with 452 ? false
Does String Kepler 452b ends with 452b ? true
Does String Kepler 452b ends with Kepler 452b ? true
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement