Merge pull request #9906 from gupta-ashu01/master

BAEL-4285
This commit is contained in:
Eric Martin 2020-08-30 11:38:46 -05:00 committed by GitHub
commit 104c00c2a1
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package com.baeldung.array.arraystoreexception;
public class ArrayStoreExampleCE {
public static void main(String[] args) {
//String array[] = new String[5]; //This will lead to compile-time error at line-8 when uncommented
//array[0] = 2;
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.array.arraystoreexception;
public class ArrayStoreExceptionExample {
public static void main(String[] args) {
try {
Object array[] = new String[5];
array[0] = 2;
} catch (ArrayStoreException e) {
// handle the exception
}
}
}