But its standard library uses checked exceptions, requiring you in turn to check them.
It uses both.
For example:
· collections use unchecked exceptions
· IO classes use checked IOException
I think the criteria used is, in general:
· when the problem arises because of a programming error an unchecked exception is thrown
(for example IndexOutOfBoundsException)
· when the problem is not a consequence of a programming error, but can be reasonably treated, a checked exception is thrown
(for example FileNotFoundException)
· when the problem is not a consequence of a programming error, but can not be reasonably treated, an Error is thrown (unchecked)
(for example OutOfMemoryError)
[Java] doesn't allow co and contravariance in its generic definitions. You cannot make a generic class that supports T (and subtypes) or T (and super types). It's T or nothing.
Java allows code like this:
[source lang="java"]
class Geometry {}
class Shape extends Geometry {}
class Circle extends Shape {}
...
List<? extends Shape> covarList = new ArrayList<Circle>();
List<? super Shape> contravarList = new ArrayList<Geometry>();
[/source]
and also
[source lang="java"]
class X<T extends Base> {}
[/source]
however the next is forbidden
[source lang="java"]
class X<T super Child> {}
[/source]