------ Solution - -------------------------------------------
< br> ------ Solution ----------------------------------------- ---
public void outPut(String strSrc)
{
for(int i=1;i<=strSrc.length();i++)
{
System.out.print(strSrc.charAt(strSrc.length()-i));
}
return ;
}
own definition , then , it can be
public static String StringReverse (String string) {
char [] charctor = string.toCharArray () ;/ / convert an array of characters
char [] char1 = new char [string.length ()] array ;/ / descending store
for (int i = 0; i
}
String string2 = new String (char1);
return string2;
}
OK the
------ Solution ---------------------------------- ----------
1 create a StringBuilder.;
2 flashbacks to traverse the original character string added to the StringBuilder . ;
3. return StringBuilder.toString () the result value ( string ) .
------ Solution ---------------------------------------- ----
positive solution, or they use a char array , reverse output
------ For reference only ----------------- ----------------------
StringBuilder sb = new StringBuilder ("abc");
sb.reverse ();
stringbuilder already done for you .
------ For reference only -------------------------------------- -
I read the source code, if the interviewer to your own definition?
------ For reference only -------------------------------------- -
I read the source code, if the interviewer to your own definition?
turn a string array , reverse output
------ For reference only ----------------- ----------------------
already have their own methods to traverse or use reverse.
------ For reference only -------------------------------------- -
I read the source code, if the interviewer to your own definition? find the value of the offset address field , then descending to write directly to memory . interviewer suddenly sb the
--- --- For reference only ---------------------------------------
descending characters Yeah string array
没有评论:
发表评论