binarySearch(Object[] a, Object key)
which means it accepts any object type for the second parameter no matter what the type of the array being passed. Therefore line 2; searching for a String in an Integer array; causes no compilation error, but causes ClassCastException at run time when trying to cast the String to an Integer.
|
Oracle Certified Professional Java Programmer
Author:
JavaChamp TeamSenior Java Developer
QuizOver.com
Germany
Access: |