标签:
package liu0917; public class Print2 { int x; void output() { if(x==1) { for(int i =65;i<=90;i++)//大写字母在char类型中的位置 { char a =(char) i; System.out.print(a); } } else if(x==2) { for(int i =97;i<=122;i++) { char a =(char) i; System.out.print(a); } } else { System.out.println("输入有误"); } } }
package liu0917; import java.util.Scanner; public class TestClass2 { public static void main(String[] args) { Print2 pr = new Print2(); Scanner sc = new Scanner(System.in); System.out.println("请输入x的值"); pr.x=sc.nextInt(); pr.output(); } }
标签:
原文地址:http://www.cnblogs.com/liuyanzeng/p/5878976.html