Java Program to Reverse a String2 min read

This post covers how to reverse a string in Java. There are various ways in the java program to reverse a String. Reversing a string means displaying the string from backward.

Consider the string reverse, we write a java program in various ways to reverse it and it will be displayed as esrever. Some of the ways to do it are using:

  • for loop
  • recursion
  • StringBuffer.

Write a program to reverse a string in Java:

Using for loop

Output: when the code is is executed it shows the following result.


Using StringBuffer:

In this method, we use reverse() method of StringBuffer class to reverse a string in java.

Output:


Using Recursion:

Output:


MORE

C Program to Check whether the entered character is capital, small letter, digit or special character

In this tutorial, we will write a program to check whether the entered character is capital, small letter, digit or any special character using C …
Read More

C Program to Check Armstrong Number

In this C programming example, we will write a program to check Armstrong Number in C. We will start with Armstrong Number. Before that, you …
Read More

C Program to Generate Random numbers within a Range

In this tutorial, you will learn to generate random numbers within a range in C programming. But before that, you may go through the topic …
Read More

C Program to Generate Random Numbers

In this C program section, we will learn how to generate random numbers in C programming. Let us start with random numbers. What is Randon …
Read More

Keith Number in Java

In this java programming tutorial, you will learn about Keith Number and its implementation in java. It is frequently asked in Java coding. What is …
Read More

Fascinating Number in Java

In this java program tutorial, we will learn about the Fascinating Number and its implementation through Java. We will check whether the number Fascinating Number …
Read More