Skip to content

Tag Archives: Java-Strings

Compare string initialization performance for String Literal and String object. String Literal String str = “GeeksForGeeks”; This is string literal. When you declare string like… Read More
Given a numeric string (length <= 32), split it into two or more integers( if possible), such that  Difference between current and previous number is… 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
The valueOf() method converts data from its internal form into a human-readable form. It is static method that is overloaded within string for all of… Read More
Write a Java program to count the characters in each word in a given sentence? Examples:  Input : geeks for geeksOutput :geeks->5for->3geeks->5 Recommended: Please solve… Read More
Write a Java Program to Swap first and last character of words in a Sentence as mentioned in the example? Examples: Input : geeks for… Read More
Prerequisite : String Comparison in Java 1. What should be the output of this program? class GeeksforGeeks {     public static void main(String args[])     {         String… Read More
Prerequisite : Basics of Strings class in java 1. What is the Output Of the following Program class demo1 {     public static void main(String args[])… 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 numbers between 6 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
Object class is present in java.lang package. Every class in Java is directly or indirectly derived from the Object class, henceforth it is a child… 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
We are given a list of words sharing a common stem i.e the words originate from same word for ex: the words sadness, sadly and… Read More
Predict the output of the program import java.util.Random; public class GFG {     private static Random rd = new Random();      public static void main(String[] args) {… Read More