How to check string from front and back?

How to check string using startsWith and endsWith function?

Let’s see videos and program on how to check string using endsWith and startsWith function.

In this blog, we will check string from front and back part. startsWith() and endsWith() functions work on check string.

 

Video On endsWith and startsWith Function


 

class str4

{

                public static void main(String args[])

                {

                                String str = “Welcome in Java String”;

                                // Want to check Welcome word first position on not

                                System.out.println(str.startsWith(“Welcome”)); // Return true

                                System.out.println(str.startsWith(“Java”));          // return false

 

                                // Let’s Check endsWith -> work same as startsWith

                                System.out.println(str.endsWith(“String”));        // return true

 

                                String employee[] = {“Patel Vijay”,”Vyas Ronit”,”Patel Dhara”,”Jain Bhaumik”,”Vyas Hitesh”};

                                String surname = “Jain”;                // Let’s Find Employee

                                for(int i=0;i<employee.length;i++)

                                {

                                                if(employee[i].startsWith(surname))     // Find start position of Surname

                                                                System.out.println(employee[i]); // Display Employee Name…

                                }

                }

}

 

Output:

True

False

True

Jain Bhaumik


[sbscrbr_form]

If you have any query on blog example, you can directly comment us or subscribe our website


Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

159total visits,0visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

1 Comment

  1. January 23, 2017 - 9:05 am

    whoah this weblog is excellent i like studying your posts. Stay up the great work! You recognize, a lot of persons are searching round for this information, you could help them greatly.

Leave a Reply

EmailEmail
PrintPrint