打印字符问题

我是绿油油茁壮的韭菜 我是绿油油茁壮的韭菜 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

public class Dome1 {
public static void main(String args[]){

char ch1='1';
char ch2='z';
int numberPerLine=10;
printChars(ch1,ch2,numberPerLine);
}
public static void printChars(char ch1,char ch2,int numberPerLine){
for(int i=(char)(ch1);i<=(char)(ch2);i++){
if(i%numberPerLine==0)
System.out.println((char)i);
else
System.out.print((char)i+" ");
}
}
}


请大家帮我看看问题出现在哪?
每行要打印10个
可是我中是打印出这样的结果

1 2
3 4 5 6 7 8 9 : ; <
= > ? @ A B C D E F
G H I J K L M N O P
Q R S T U V W X Y Z
[ \ ] ^ _ ` a b c d
e f g h i j k l m n
o p q r s t u v w x
y z

请大家帮我改改!
一定要用这个方法头的public static void printChars(char ch1,char ch2,int numberPerLine)
我每份给,不好意思吖!
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部