Which piece of code executes faster in Java?
List<Object> list = new ArrayList<Object>();
Object firstObject = null;
if (!list.isEmpty()) {
firstObject = list.get(0);
}
or
List<Object> list = new ArrayList<Object>();
Object firstObject = null;
try {
firstObject = list.get(0);
} catch (IndexOutOfBoundsException e) {
}