1、
Given the string, check if it is a?palindrome.(回文)
Example
- For?
inputString = "aabaa"
, the output should becheckPalindrome(inputString) = true
; - For?
inputString = "abac"
, the output should becheckPalindrome(inputString) = false
; - For?
inputString = "a"
, the output should becheckPalindrome(inputString) = true
.
解法:
????? ? 字符串和字符數組的轉換:
String strStringType =
"my string"
;
//創建一個字符串變量strStringType
char
[] chrCharArray;
//創建一個字符數組chrCharArray
chrCharArray = strStringType.toCharArray();
//將字符串變量轉換為字符數組
strStringType = String.valueOf(chrCharArray);
//將字符數組轉換為字符串