import java.util.*;
class ArrayOverflowException extends Exception{
ArrayOverflowException(){
super();
}
static int i;
static void check(int i) throws ArrayOverflowException{
if (i>5) {
throw new ArrayOverflowException("Array Overflow");
return;
}
}
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int a[]=new int[5];
System.out.println("Enter the elemets of the array. #MAX 6 ELEMENTS#");
try{
for (int i=0;i<10;i++) {
ArrayOverflowException.check(i);
a[i]=input.nextInt();
}
}catch (ArrayOverflowException e) {
System.out.println("Exception handled"+e);
}
}
}
나는 오류 cannot find symbol in line 9
을주는 Java에서 내 자신의 사용자 정의 예외를 만들려고했습니다. 도와주세요.Java에서 사용자 정의 오류 만들기. 이 코드가 왜 작동하지 않습니까?
9 호는 새로운 ArrayOverflowException ("Array Overflow")을 던집니다.
변화를'에 대한 (INT I = 0; i가 10 <; 내가 ++) {'내가 이미 시도 –
가 그 일을하고 라인 9 인 차이 – Palak
을하지 않았다? – shmosel