Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

reverse string in java

String reverse = new StringBuilder(string).reverse().toString();
Comment

reverse a string in java

public class StringReverseExample{
   public static void main(String[] args) {
      String string = "abcdef";
      String reverse = new StringBuffer(string).reverse().toString();
      System.out.println("
String before reverse: "+string);
      System.out.println("String after reverse: "+reverse);
   }
}
Comment

how to reverse a string in java

public class ReverseString {
    public static void main(String[] args) {
        String s1 = "neelendra";
        for(int i=s1.length()-1;i>=0;i--)
            {
                System.out.print(s1.charAt(i));
            }
    }
}
Comment

string reverse in java

String str = "Hello";
String reverse(String str){
  StringBuilder sb = new StringBuilder();
  sb.append(str);
  sb.reverse();
  return sb.toString();
}
Comment

java reverse string

// Not the best way i know but i wanted to challenge myself to do it this way so :)
public static String reverse(String str) {
  char[] oldCharArray = str.toCharArray();
  char[] newCharArray= new char[oldCharArray.length];
  int currentChar = oldCharArray.length-1;
  for (char c : oldCharArray) {
    newCharArray[currentChar] = c;
    currentChar--;
  }
  return new String(newCharArray);
}
Comment

Reverse a String in Java

public class ReverseStringByFavTutor

{

   public static void main(String[] args) {


       String stringExample  =  "FavTutor";

       System.out.println("Original string: "+stringExample);


       // Declaring a StringBuilder and converting string to StringBuilder

       StringBuilder reverseString = new StringBuilder(stringExample);


       reverseString.reverse();  // Reversing the StringBuilder


       // Converting StringBuilder to String

       String result = reverseString.toString();


       System.out.println("Reversed string: "+result); // Printing the reversed String


   }

}
Comment

java String revers

 public static void main(String[] args)
    {
        String input = "Geeks for Geeks";
 
        StringBuilder input1 = new StringBuilder();
 
        // append a string into StringBuilder input1
        input1.append(input);
 
        // reverse StringBuilder input1
        input1.reverse();
 
        // print reversed String
        System.out.println(input1);
    }
Comment

String reverse in java

1)
String str = "Hello";
String result = "";

  for(int i = str.length()-1; i>=0; i--){
     result += str.charAt(i); // first solution, charAt method
 //  result += str1.substring(i, i+1); // first solution,  substring method
   }
   System.out.println(result);
}

Comment

String reverse in Java

StringBuilder sb1 = new StringBuilder("Mahmut");
        sb1.reverse();
        System.out.println(sb1); // tumhaM
Comment

PREVIOUS NEXT
Code Example
Java :: cors spring 
Java :: linear search algorithm java 
Java :: check each character in a string java 
Java :: java android development find element by id 
Java :: labelled break statement in Java 
Java :: min in java 
Java :: public class in java 
Java :: sorting list in java 
Java :: bytearrayoutputstream 
Java :: java int array to integer arraylist 
Java :: equals ignore case java 
Java :: java base64 to file 
Java :: java arraylist add 
Java :: java php object 
Java :: copying primitive array to arraylist in java 
Java :: Calling User-Defined Method in Java 
Java :: important features of java programming language 
Java :: setting java home 
Java :: java how to print out a string in uppercase 
Java :: binary search java 
Java :: flutterwave BVN api 
Java :: tableau deux dimensions java 
Java :: isEmpty java code 
Java :: android iterate through radio group java 
Java :: java parse json to class 
Java :: vue composition watch 
Java :: java array get index 
Java :: remove tableview separator lines in javafx 
Java :: How to merge two sorted arrays? 
Java :: Error: Could not find or load main class Main Caused by: java.lang.ClassNotFoundException: Main 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =