【习题32】

作者: Xplorist | 来源:发表于2017-04-18 07:01 被阅读17次

    【程序32】
    题目:取一个整数a从右端开始的4~7位。

    package com.share.test31_40;
    
    public class Test32 {
        public static void main(String[] args) {
            test();
        }
        public static void test(){
            long a=1234567890;
            String s=String.valueOf(a);
            int count=0;
            for(int i=s.length()-1;i>=0;i--){
                count++;
                if(count>=4&&count<=7){
                    System.out.println(s.charAt(i));
                }
            }
        }
    }   
    
    

    相关文章

      网友评论

        本文标题:【习题32】

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