package com.bdqn.theseventhchapter;
/**
*
* 第7章异常 第3题访问数组下标越界
*/
public class Test {
public static void main(String[] args) {
try {
int[] num = new int[] { 11, 22, 33 };
for (int i = 0; i < num.length; i++) {
}
System.out.println(num[0]);
System.out.println(num[1]);
System.out.println(num[2]);
System.out.println(num[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("访问数组下标越界");
e.printStackTrace();
}
*
* 第7章异常 第3题访问数组下标越界
*/
public class Test {
public static void main(String[] args) {
try {
int[] num = new int[] { 11, 22, 33 };
for (int i = 0; i < num.length; i++) {
}
System.out.println(num[0]);
System.out.println(num[1]);
System.out.println(num[2]);
System.out.println(num[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("访问数组下标越界");
e.printStackTrace();
}
}
}
package com.bdqn.theseventhchapter;
/**
* 第7章第5题修改第三题使用log4j记录日志
*/
import java.util.logging.Logger;
* 第7章第5题修改第三题使用log4j记录日志
*/
import java.util.logging.Logger;
public class Test1 {
private static Logger logger = Logger.getLogger(Test1.class.getName());
public static void main(String[] args) {
try {
int[] num = new int[] { 11, 22, 33 };
for (int i = 0; i < num.length; i++) {
}
System.out.println(num[0]);
System.out.println(num[1]);
System.out.println(num[2]);
System.out.println(num[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("访问数组下标越界");
e.printStackTrace();
}
}
try {
int[] num = new int[] { 11, 22, 33 };
for (int i = 0; i < num.length; i++) {
}
System.out.println(num[0]);
System.out.println(num[1]);
System.out.println(num[2]);
System.out.println(num[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("访问数组下标越界");
e.printStackTrace();
}
}
}