题解 | #字符逆序#--使用SB的reverse()方法

字符逆序

https://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<String> result = new ArrayList<>();
        // 使用StringBulider/StringBuffer的reverse()方法
        while (in.hasNextLine()) {
            StringBuilder sb = new StringBuilder(in.nextLine());
            sb.reverse();
            System.out.println(sb.toString());
        }
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务