“string terbalik di java” Kode Jawaban

cara membalikkan string di 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));
            }
    }
}
Annoying Anaconda

membalikkan string di java

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

String Reverse di Java

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

Java String terbalik

 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);
    }
Malik Kaki

string terbalik di java

String s = "abcde";
s.reverse();
System.out.println(s);

//s == "edcba"
Perfect Porcupine

string terbalik di java

public static String reverse(String str) 
{
    String rev="";
    char[] finalarray = str.toCharArray();
    for (int i = finalarray.length - 1; i >= 0; i--)
        rev+=finalarray[i];
    return rev;
}
//Sample Input- "Scaler Academy"
//Sample Output-"ymedacA relacS"
codelearner

Jawaban yang mirip dengan “string terbalik di java”

Pertanyaan yang mirip dengan “string terbalik di java”

Lebih banyak jawaban terkait untuk “string terbalik di java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya