罗列计数器(工具类)

以前一直想写一个类,能指定无限大小,模拟整数的增长,依次加一,下面是代码

package com.bird.software; public class Test { private static int [] nums = new int[21]; private static int count = 20; public static void main(String[] args){ for(int i = 0; i < 21; i++){ nums[i]= 0; } while(true){ if(nums[0] == 9)break; for(int i = 0; i < 10; i++){ nums[20]=i; for(int t : nums) System.out.print(t); System.out.println(); } add(nums); count = 20; for(int t : nums) System.out.print(t); System.out.println(); } } public static void add(int [] num){ if(num[count]==9){ num[count]=0; if(num[count-1]!=9) num[count-1] = num[count-1] + 1; else { count = count - 1; add(num); } } } }
运行效果如下,局部

000000000000000014689 000000000000000014690 000000000000000014690 000000000000000014691 000000000000000014692 000000000000000014693 000000000000000014694 000000000000000014695 000000000000000014696 000000000000000014697 000000000000000014698 000000000000000014699 000000000000000014700 000000000000000014700 000000000000000014701 000000000000000014702 000000000000000014703 000000000000000014704 000000000000000014705 000000000000000014706 000000000000000014707 000000000000000014708 000000000000000014709 000000000000000014710 000000000000000014710 000000000000000014711 000000000000000014712 000000000000000014713 000000000000000014714 000000000000000014715 000000000000000014716 000000000000000014717

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值