- String[] tr = word.split(" ");
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < tr.length; i++) {
- char[] cr = tr[i].toCharArray();
- for (int j = cr.length - 1; j >= 0; j--) {
- sb.append(cr[j]);
- }
- sb.append(" ");
- }
- System.out.println(sb.toString());
复制代码 |
|