美文网首页
for循环递减写法

for循环递减写法

作者: 拄杖忙学轻声码 | 来源:发表于2021-09-23 14:48 被阅读0次

代码:

        String testStr = "abcdef";
        for (int i = testStr.length() - 1; i >= 0; i--) {
            String subStr = testStr.substring(0, i + 1);
            if(StrUtil.isNotBlank(subStr)){
                System.out.println("subStr = " + subStr);
            }
        }

输出:


image.png

相关文章

网友评论

      本文标题:for循环递减写法

      本文链接:https://www.haomeiwen.com/subject/qzxggltx.html