String methods – Concat and contains

In this post, we will see 2 string methods which are  concat and contains.

String concat(String str):

The method appends a specified string to the end of this string.

If the length of the string is 0, after concatenating a new string will return. We can concatenate multiple strings as well as shown in the code below.

Output:
New string object
Hello world!!How are you.

boolean contains(CharSequence s):

This method finds the sequence of characters in the any string and returns true if matches ,else false.

Output:
true
false
Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
String methods - charAt() and compareTo()
String methods - startsWith and endsWith
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...