Operation On Strings In JAVA

Operation On Strings In JAVA

We are going to perform 3 basic operation on String:

1.Calculating Length of String.

Its very easy in java using length() function.
It will return int value of the string including spaces.
Check below code for better understanding

2.Concatenation of Strings.

There are two basic ways to concatenate a string using "+" operator or using concat() function.
Both ways are implemented in code below.

2.String Comparison.

Strings can be compared using compareTo() function in java.
Which will return integer value that is difference of different alphabets in a string.
Check below code for better understanding

Code