How to Reverse a String in java in Hindi word by word example

Last Updated: June 2, 2024 by admin

How to reverse a string in Java ya phir simply reverse string in Java kaise karein. Ye wo bohat hi asking question hai internet par jo ki bohat sare Indians isko puchte hain.

Aisi bohat sari cheezein hoti Hain. Jinko ham asaan bhasha mein Janna chahte hain. Aur aj ka Mera ye article isi ke upar hai.

Jismein mein apko iski puri jankari dunga ke kese ap string ko back kar sakte ho Java mein wo bhi asani se. Mein ye sab apko code ke tehat samjhane ki koshish karunga.

Iske liye apko kuch zyada nahi karna hai, bs mere is article ko pura padna hai. Jisse ke ap ek bhi word ko miss nahi kar paoge.

Aur apko kafi help bhi milegi. To chaliye dosto agar ap iske baare mein jaana na chahte hain.

To aap sahi jagah par aye ho kyunki is an article, mein main aapko how to reverse a string in Java ke baare mein batane wala hoon.

How to Reverse a String in java
How to reverse a string in java using for loop

How to Reverse a String in Java 2024

Agar ap Java mein koi bhi kaam kar rahe ho. To wahan par apko ek bohat hi beneficial term dikhaegi string ko reverse karna. Isi liye agar ap string buffer in java in Hindi ke bare mein janna chahte hain to iska jawab bhi mere is article mein mil jaega.

Aur har tarah ke developers agar isko first time sunte hain. To unko aisa lgta hai ke ye pta nahi Kya nayi bala aa gayi hai.

But friends aisa bilkul bhi nahi hai. Ye ek bohat hi easy cheez hai agar ap isko smjh ke karoge to apko bohat hi asan lagega.

Wese to aur bhi bohat sari interesting cheezein Hain. Lekin aj jiske bare mein ham baat karenge.

Wo bhi ek bohat hi badiya cheez hai janne ke liye ke hum string ko reverse kaise karte hain Java mein. Yeh ek aisa question hai, jo ki bahut sare interview mein bhi pucha jata hai.

Isi beech mein main aapko Hindi mein batane wala hoon ke hum reverse a string in Java kaise karte hain.

Aur main inki examples bhi dunga aur un methods ke bare mein bhi btaunga. Jin method se hum aisa kaam kar sakte hain. जिसकी मदद से आपको एक आईडी अभी हो जाएगा.

Chaliye dosto is ke baare mein puri jankari jaan lete hain. Aur agar apko ye article badiya laga to please ise ap apne dosto ke sath share bhi zarur karna.

Also Read: Best Names for PUBG

How to reverse string in Java in hindi

What is reverse string in java (English)?

In Java, a string can be reversed by using different methods. One of the most common methods to reverse a string in Java is by using a StringBuilder or StringBuffer class.

Here’s an example of how to reverse a string using StringBuilder in Java:

String originalString = “Hello World”;
StringBuilder reversedString = new StringBuilder();

reversedString.append(originalString);
reversedString = reversedString.reverse();

System.out.println(“Original string: ” + originalString);
System.out.println(“Reversed string: ” + reversedString.toString());

Output:

Original String: Hello World
Reversed String: dlroW olleH

In this example, we first declare a string variable originalString and assign it the value “Hello World”. Then, we declare a StringBuilder variable reversedString and initialize it as an empty string.

Next, we append the original string reversedString using the append method. We then use the reverse method of the StringBuilder class to reverse the string. Finally, we print both the original and reversed strings using the System.out.println method.

Reverse a String in Java

Mene ye sare methods one by one karke diye huye hain. Apko bs inko padna hai aur khud implement karna hai.

Jisse apko bohat hi zyada faida hoga. Jese ki mene apko ek bohat badiya tarike se article smjhaya tha how to improve handwriting in Hindi.

Isko bhi alko same usi tarah implement karna hai. Aur kahin par mistake ho jati hai to phir se check karke dubara se try krni hai.

Also Read: CRPF Pay Slip, Pay slip CRPF कैसे देखें

1) Reverse a string in Java by using StringBuffer or StringBuilder

Jaisa ki hum sab jante hain ki stringBuffer and StringBuilder dono hi string ko reverse karne ke kaam aate hain.

Aur agar hum isko reverse karna chahte hain Java main to stringbuffer ya phir stringbuilder bohat hi helpful rahenge.

Iski examples niche di gayi hai program ke sath:
String input = “exotic”;
StringBuilder sb = new StringBuilder(input);
String result = sb.reverse().toString();
System.out.println(result); //prints ‘citoxe’

Also Read: Top Law Colleges in India

Stringbuffer

2) Reverse a string in Java by using an external class

Agar aap string ko reverse karte hain external class ki method se. To bhi ap isko easily reverse karoge Java mein. Iski example bhi niche di gayi hai with program ke sath:

 import java.util.Scanner;
  public class ReverseString
 {
     public static void main(String[] args)
     {
         System.out.println("Exotic");    
Scanner read = new Scanner(System.in);
    String str = read.nextLine();
    String reverse = "";

    for(int i = str.length() - 1; i >= 0; i--)
    {
        reverse = reverse + str.charAt(i);
    }

    System.out.println("citoxE");
    System.out.println(reverse);
}
}

Also Read: Best MBA Colleges in Delhi

External class

3) Reverse a string in Java by Reverse Iteration

Reverse Itration se bhi hum isko reverse kar sakte hain Java mein. I think ye ek bohat hi important method hai aur Mera favorite bhi.

Iski example bhi niche di gayi hai aur program ke sath:

public class TestStringFormatter {
public static void main(String[] args) {
System.out.println(StringFormatter.reverseString(“Exotic”));
}
}
Output:
citoxE

Also Read: Formula of plaster of paris

Reverse iteration in how to reverse a string in java

4) Reverse a string in Java by Array

Agar aap isko reverse karna chahte hain Java mein to array aapke liye Best sabit ho sakta hai.

Personally mene isko khud use kiya hua hai. Aur ye result show kar deta bai within a few seconds mein. With the help of array hum isko bohat hi asani se reverse kar sakte ho Java main.

Also Read: General Knowledge Question and Answers in Hindi

Iski example bhi niche di gayi hai aur program ke sath:

class ReverseofaString
{
public static void main(String[ ] arg)
{
String str;
Scanner scan=new Scanner(System.in);
System.out.print(“Enter a string : “);
str=scan.nextLine();
char[] ch=str.toCharArray();
System.out.println(“Reverse of a String is : Exotic”);
int j=ch.length;
for(int i=j;i>0;i–)
{
System.out.print(ch[i-1]);
}
}
}
Output:
citoxE

Also Read: Best Military School in India

Java program to reverse a string

Here is a program to reverse a string in Java written by a qualified teacher:

public class Reverse   

{    

    public static void main(String[] args) {    

        String string = “Dream big”;    

        //Stores the reverse of given string    

        String reversedStr = “”;    

            

        //Iterate through the string from last and add each character to variable reversedStr    

        for(int i = string.length()-1; i >= 0; i–){    

            reversedStr = reversedStr + string.charAt(i);    

        }    

            

        System.out.println(“Original string: ” + string);    

        //Displays the reverse of given string    

        System.out.println(“Reverse of given string: ” + reversedStr);    

    }    

}    

Agar apko phir bhi pta nahi chal rha hai. To don’t worry ap Meri taraf se hindi video dekhiye. Jahan par bohat hi asani se inhone samjhaya hua hai:

Posts jo apko achi lgengi

Final Words

Toh Dosto aaj ke is article mein maine aapko bataya how to reverse a string in java aur reverse a String in java, Armstrong number in java.

Main poori umeed karta hun ki aapko how to reverse a string in java aur reverse a String in java ke bare mein puri jankari bahut hi acchi lagi hogi.

Agar apke pas koi bhi doubt hai ya phir koi bhi sawal hai jo aap hamse puchne chahte ho. Toh niche comment kark aap apna wo doubt ya phir question puch skte hain.
Thanks.

FAQs

Q. Which constructs an anonymous inner class instance?

Ans. Runnable r = new Runnable() { };

Q. How many ways to reverse a string in java?

Ans. 5 Different ways.

Leave a Comment