The inverse of string in Java is the most proposed method:
public void Convertstr (string str) {//Converts a string object to a StringBuffer class object that can be changed//and then calls the reverse () method of the StringBuffer class to implement the inversion String strreverse=new stringbuffer (str). reverse (). toString (); System.out.println (StrReverse); }
Other methods:
public void Convertstr (String str) {for (int i=str.length () -1;i>=0;i--) {//output one character per reverse System.out.print (Str.charat (i)); } }
A less desirable approach: trouble
public void convertstr (STRING&NBSP;STR) { string strnew= ""; string [] s=new string[str.length ()]; for (int x=0;x< Str.length ();x++ ) { s[x]=str.substring (x,x+1); } for (Int x=str.length () -1;x >=0;x-- ) { strnew+=s[x]; } system.out.println (strnew); }
Inversion of Java strings