Skip to content

Tag Archives: Java-String-Programs

Given a string, the task is to find all the palindromic sub-strings from the given string. In Set – 1, another approach has been already… Read More
The following programs demonstrates how to remove the white spaces using matcher.replaceAll(String replacement) method of Util.regex.Pattern class. The java.util.regex.Matcher.replaceAll(String replacement) method replaces every subsequence of… Read More
In Java we can append a string in an existing file using FileWriter which has an option to open file in append mode. Java FileWriter… Read More
Consider the following codes in java: // This program prints false class GFG {      public static void main(String[] args) {     StringBuffer sb1 = new… Read More
Write a Java program to take an input string and exchange the first and last word and revers the middle word.Examples:   Input : Hello World… Read More
Suppose we have given a String in which some ranges as specified and we have to place the numbers which is between the given range… Read More
Given a string str with uppercase, lowercase and special characters. The input string is to end with either a space or a dot. The problem… Read More
Mobile Number validation criteria: The first digit should contain number between 7 to 9. The rest 9 digit can contain any number between 0 to… Read More
String Interning is a method of storing only one copy of each distinct String Value, which must be immutable. By applying String.intern() on a couple… Read More
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
String class doesn’t have any method that directly sort a string, but we can sort a string by applying other methods one after other. Method… Read More
There are two variants of substring() method.This article depicts about 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