how to reverse a string in java | Ways of reversing a String in java | Solution

Publicado em: 10 Novembro 2022
no canal de: human compiler
7
0

how to reverse a string in java | Ways of reversing a String in java | Solution
In this video i am writing program of reversing a string in java. There are many ways to reverse a string in java.
package com;


// First way of reversing a string in java (Using String Buffer)

/***public class reverse {

public static void main(String[] args) {
// TODO Auto-generated method stub

StringBuffer r=new StringBuffer("Human Compiler");
System.out.println(r.reverse());

}

}

//Second way of reversing a string in java (Using String Builder)
public class reverse {

public static void main(String[] args) {
// TODO Auto-generated method stub

StringBuilder r=new StringBuilder("Human Compiler");
System.out.println(r.reverse());

}

}
***/

//Third way of reversing a string in java

public class reverse {

public static void main(String[] args) {
// TODO Auto-generated method stub

String s1="";
String str="human";
int s=str.length();

for(int i=s-1;i=0;i--) { (Angle bracket missed here..)
s1=s1+str.charAt(i);
}
System.out.println(s1);

}

}

This is the code. you can just copy from here and paste it in your editor.


Nesta página do site você pode assistir ao vídeo on-line how to reverse a string in java | Ways of reversing a String in java | Solution duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário human compiler 10 Novembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 7 vezes e gostou 0 espectadores. Boa visualização!