43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
public class Switch1 {
|
|
public static void main(String[] args) {
|
|
Switch1 s1= new Switch1();
|
|
s1.testOne(args);
|
|
s1.testTwo(args);
|
|
s1.testThree(args);
|
|
}
|
|
|
|
public void testOne(String[] args) {
|
|
char ch;
|
|
switch(Integer.parseInt(args[0])) {
|
|
case 0: ch=Character.forDigit(Integer.parseInt(args[1]), 10); break;
|
|
case 1: ch=Character.forDigit(Integer.parseInt(args[2]), 10); break;
|
|
case 2: ch=Character.forDigit(Integer.parseInt(args[3]), 10); break;
|
|
case 3: ch=Character.forDigit(Integer.parseInt(args[4]), 10); break;
|
|
default: ch= '?'; break;
|
|
}
|
|
System.out.println(ch);
|
|
}
|
|
|
|
public char testTwo(String[] args) {
|
|
switch(Integer.parseInt(args[0])) {
|
|
case 0: return Character.forDigit(Integer.parseInt(args[1]), 10);
|
|
case 1: return Character.forDigit(Integer.parseInt(args[2]), 10);
|
|
case 2: return Character.forDigit(Integer.parseInt(args[3]), 10);
|
|
case 3: return Character.forDigit(Integer.parseInt(args[4]), 10);
|
|
default: return '?';
|
|
}
|
|
}
|
|
|
|
public void testThree(String[] args) {
|
|
char ch = '?';
|
|
switch(Integer.parseInt(args[0])) {
|
|
case 0: ch=Character.forDigit(Integer.parseInt(args[1]), 10); break;
|
|
case 1: ch=Character.forDigit(Integer.parseInt(args[2]), 10); break;
|
|
case 2: ch=Character.forDigit(Integer.parseInt(args[3]), 10); break;
|
|
case 3: ch=Character.forDigit(Integer.parseInt(args[4]), 10); break;
|
|
}
|
|
System.out.println(ch);
|
|
}
|
|
|
|
}
|