编写一个类,该类创建的对象可以输出英文字母表
展开全部
public class BB {
public BB(boolean isUppperCase){
char start = isUppperCase? 'A':'a';
char end = isUppperCase? 'Z':'z';
while(start <= end){
System.out.print(start);
start++;
}
System.out.println();
}
public BB(){
this(false);
}
public static void main(String[] args) {
new BB();//默认输出小写字目标
System.out.println();
new BB(true);//大写就传参数true
}
}
-----------testing
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
public BB(boolean isUppperCase){
char start = isUppperCase? 'A':'a';
char end = isUppperCase? 'Z':'z';
while(start <= end){
System.out.print(start);
start++;
}
System.out.println();
}
public BB(){
this(false);
}
public static void main(String[] args) {
new BB();//默认输出小写字目标
System.out.println();
new BB(true);//大写就传参数true
}
}
-----------testing
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询