What is String in Java?

A String is an object of the String class, which is part of the java.lang package. A String can be created by using the String literal: 

syntax: String name = "John";

By using the new keyword and the constructor of the String class:

Syntax: String name = new String("John");

Java String class provides a lot of methods to perform operations on strings such as compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(), substring() etc.

Java String Programs

A String in Java is a sequence of characters that can be used to store and manipulate text data and It is basically an array of characters that are stored in a sequence of memory locations. All the strings in Java are immutable in nature i.e. once the string is created we can’t change it. This article provides a variety of programs on strings, that are frequently asked in the technical round in various software engineering interviews including various operations such as reversing, Iteration, palindrome, swapping, and splitting of strings etc.

Here, you practice all basic to advanced programs related to strings and each program comes with a detailed description, Java code, and output. All of the examples have been thoroughly tested on both Windows and Linux systems.

  • Basic Strings Questions
  • Advance Strings Questions

Similar Reads

What is String in Java?

A String is an object of the String class, which is part of the java.lang package. A String can be created by using the String literal:...

Java String Programs for Practice: Complete List

Here is a complete list of Java String practice programs divided into basic and advance category :...

Java String Programs: Basic Strings Questions with Solutions

Java String Program to Print even length words Java String Program to Insert a string into another string Java String program to check whether a string is a Palindrome Java String Program to Check Anagram Java String Program to Reverse a String Java String Program to Print a New Line in String Java String Program to  Add Characters to a String Java String Program to Iterate Over Characters in String Java String Program to Convert Enum to String Java String Program to Get a Character From the Given String Java String Program to Convert String to String Array Java String Program to Swapping Pair of Characters Java String Program to Splitting into a number of sub-strings...

Java String Programs: Advance Strings Questions with Solutions

Java String Program to Replace a Character at a Specific Index Java String Program to Remove leading zeros Java String Program to Reverse a String Using Stacks Java String Program to Sort a String Java String Program to Convert String to InputStream Java String Program to Check Whether the Given String is Pangram Java String Program to Print the first letter of each word using regex Java String Program to Determine the Unicode Code Point at a given index Java String Program to Compare two strings Java String Program to Compare two strings lexicographically...

Conclusion

In Conclusion, By practising these Java String questions you will get enough confidence to face any string questions in your upcoming Interview....

Java Strings Programs – FAQs

1. What is string with example?...