In the first case, you need to instantiate a specific type. In the second you leave it to the implementer to decide which type to return.
I am not familiar with Bitmap, but another example is EnumSet. When you call:
EnumSet<SomeEnum> set = EnumSet.noneOf(SomeEnum.class);
the static factory method uses a different implementation depending on the number of items in your enum to be as efficient as possible in all situations.
The underlying code returns either a RegularEnumSet
for small enums or a JumboEnumSet
for large enums. That kind of contextual optimisation would not be possible with a constructor.
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) {
Enum[] universe = getUniverse(elementType);
if (universe == null)
throw new ClassCastException(elementType + " not an enum");
if (universe.length <= 64)
return new RegularEnumSet<>(elementType, universe);
else
return new JumboEnumSet<>(elementType, universe);
}