Skip to content

Tag Archives: Java-String-Programs

In this article, we will discuss how we can compare two strings lexicographically in Java. One solution is to use Java compareTo() method. The method… Read More
array.length: length is a final variable applicable for arrays. With the help of the length variable, we can obtain the size of the array.  string.length()… Read More
The string class doesn’t have any method that directly sorts a string, but we can sort a string by applying other methods one after another.… Read More
There are two variants of the substring() method. This article depicts all of them, as follows :  1. String substring(): This method has two variants… Read More
Sorting a collection of objects can be done in two ways:  By implementing Comparable (Natural Order) e.g. Strings are sorted ASCIIbetically. meaning B comes before… Read More
Let’s see an approach to reverse words of a given String in Java without using any of the String library function Examples: Input : "Welcome… Read More
As we know that Object of String in Java are immutable (i.e. we cannot perform any changes once its created). To do modifications on string stored… Read More
Given a string, extract the first letter of each word in it. “Words” are defined as contiguous strings of alphabetic characters i.e. any upper or… Read More
Given a string, extract the first letter of each word in it. “Words” are defined as contiguous strings of alphabetic characters i.e. any upper or… Read More
Write a function that takes a String as an argument and prints all unique words in it. Examples: Input : Java is great. Grails is… Read More
Given a string, extract words from it. “Words” are defined as contiguous strings of alphabetic characters i.e. any upper or lower case characters a-z or… Read More
In the article Check if a given string is a valid number, we have discussed general approach to check whether a string is a valid… Read More
Given a string, count the total number of vowels (a, e, i, o, u) in it. There are two methods to count total number of… Read More
Given a string of digits, remove leading zeros from it. Illustration:  Input : 00000123569 Output : 123569 Input : 000012356090 Output : 12356090 Recommended: Please… Read More
Prerequisite: StringJoinerStringJoiner is very useful, when you need to join Strings in a Stream. Task : Suppose we want the string “[George:Sally:Fred]”, where we have given… Read More

Start Your Coding Journey Now!