commit
104c00c2a1
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user