1 package com.hanqi.z1p1; 2 3 public class Print1 { 4 5 6 void output(int x) 7 { 8 9 if(x==1) 10 { 11 for(char i='A';i<'Z';i++) 12 { 13 System.out.print(i+" "); 14 } 15 }else if(x==2) 16 { 17 System.out.println(); 18 for(char i='a';i<'z';i++) 19 { 20 System.out.print(i+" "); 21 } 22 }else 23 { 24 System.out.println(); 25 System.out.println("请输入1或2"); 26 } 27 } 28 29 30 public static void main(String[] args) { 31 // TODO 自动生成的方法存根 32 33 34 Print1 pr1=new Print1(); 35 pr1.output(1); 36 37 Print1 pr2=new Print1(); 38 39 pr2.output(2); 40 41 Print1 pr3=new Print1(); 42 pr3.output(3); 43 44 45 46 } 47 48 }
运行结果: