String Handling in Java

Amar Balu
The Fresh Writes
Published in
4 min readApr 4, 2023

--

Java is a popular programming language that is widely used in various industries. One of the essential features of Java is its string handling capabilities. In Java, strings are a sequence of characters that are used to store and manipulate text-based data. Java provides a vast range of string handling techniques that programmers can use to perform various operations on strings. In this article, we will discuss various string handling techniques in Java.

Image Source : https://javadeveloperzone.com/spring-boot/spring-boot-tutorial/

String Concatenation:

String concatenation is the process of combining two or more strings to form a single string. In Java, we can use the "+" operator to concatenate two or more strings.

Example:

String str1 = "Hello";
String str2 = "World";
String result = str1 + str2;
System.out.println(result); // Output: HelloWorld

String Length:

The length() method in Java returns the length of the string. It returns the number of characters present in the string, including white spaces.

Example:

String str = "Hello World";
int len = str.length();
System.out.println(len);
Output for the above program is as follows
11

Substring:

--

--

Amar Balu
The Fresh Writes

I'm a front-end developer. I love React and Redux, Java, and Data Science. I write code for fun!. Join our publication : https://medium.com/thefreshwrites