Reading other people\'s code, I\'ve seen a lot of:
List ints = new ArrayList();
Map map = new HashMap();
@Bhushan answered why. To answer your confusion Why nobody uses
CharSequence s = new String("String");
or
OutputStream out = new PrintStream(OutputStream);
CharSequence
contains only few common methods. Other classes that implement this interface are mostly buffers and only String
is immutable. CharSequence
defines common api for classes backed by char array and This interface does not refine the general contracts of the equals and hashCode methods (see javadoc).
OutputStream
is low-level api for writing data. Because PrintStream
adds extra convenient methods for writing - higher level of abstraction, it's used over OutputStream.