Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to check the start and end of a String

Posted By: Abagail Cohen     Category: Java     Views: 3269

A Java Program to check the start and end of a String.

Code for Program to check the start and end of a String in Java

publicclass JAVA_047
 {

    publicstaticvoid main(String[] args)
    {
       String Str="Too many cooks";

       System.out.println("Str : " + Str);

       if(Str.startsWith("Too"))
          System.out.println("The String Str start with the sub-string \"Too\"");

       else
          System.out.println("The String Str do not start with the sub-string \"Too\"");

       if(Str.endsWith("COoks"))
          System.out.println("The String Str start with the sub-string \"COoks\"");

       else
          System.out.println("The String Str do not start with the sub-string \"COoks\"");
    }
 }
  
Share: 


Didn't find what you were looking for? Find more on Program to check the start and end of a String Or get search suggestion and latest updates.

Abagail Cohen
Abagail Cohen author of Program to check the start and end of a String is from Jerusalem, Israel.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!