嗨我想扭轉字符串,使迴文。有人可以給我一個關於如何扭轉字符串的教程嗎?我已經在線閱讀了一些教程,並試圖將它們應用到我正在編寫的迴文計劃中,但未取得成功。反向字符串迴文
import java.util.Random;
public class IterativePalindromGenerator {
public static void main(String[] args) {
Random random = new Random();
int floorValue = 1;
int cielingValue = 20;
int randomNumber = random.nextInt(cielingValue - floorValue)
+ floorValue;
String alphabetLetters = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < randomNumber; i++) {
char generatedLetters = alphabetLetters.charAt(random
.nextInt(alphabetLetters.length()));
String generatedLetterSTRINGType = Character
.toString(generatedLetters);// converts char to string
System.out.print(generatedLetterSTRINGType);
}
}
}
[檢查此鏈接,並相應地改變對迴文結構。] [1] [1]:http://stackoverflow.com/a/27171827/4295340 –