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.
En esta página del sitio puede ver el video en línea how to reverse a string in java | Ways of reversing a String in java | Solution de Duración hora minuto segunda en buena calidad , que subió el usuario human compiler 10 noviembre 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 7 veces y le gustó 0 a los espectadores. Disfruta viendo!