1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class JBT5101 { public static void main(String args[]) { char CHA[]; CHA = new char[4]; CHA[0] = 'A'; CHA[1] = 'B'; CHA[2] = 'C'; CHA[3] = 'D'; show(CHA, "CHA"); char CHB[] = {'1', '2', '3', '4', '5'}; show(CHB, "CHB"); char CHC[] = new char[3]; CHC[0] = 'a'; CHC[1] = 'b'; CHC[2] = 'c'; show(CHC, "CHC"); }
static void show(char chs[], String str) { for (int i = 0; i < chs.length; i++) { System.out.println(str + "[" + i + "]=" + chs[i]); } } }
|