![]() |
VOOZH | about |
Strings are one of the most commonly used data types in programming. In Java, a String represents a sequence of characters and provides many built-in methods to manipulate and process text data efficiently.
Let’s discuss some common String operations in Java along with their implementation.
To access any character in a String, we need:
Using this Approch the character can be easily accessed using the below syntax:
char ch = s.charAt(k);Below is the implementation of the above approach:
To insert any Character/String in a String, we need:
Below is the implementation of the above approach:
Original String : GeeksGeeks Modified String : GeeksforGeeks
To modify any Character in a String, we need:
Below is the implementation of the above approach:
Original String = Geeks Gor Geeks Modified String = Geeks For Geeks
To delete any Character in a String, we need:
Below is the implementation of the above approach:
eeksforeeks
To concatenate any String to a String, we need:
Below is the implementation of the above approach:
this is init added now
To find the length of the String, we need:
Below is the implementation of the above approach:
13
String comparison is used to check if two strings are equal or to determine their lexicographic order.