Reading other people\'s code, I\'ve seen a lot of:
List ints = new ArrayList();
Map map = new HashMap();
List ints = new ArrayList();
If you write some code that deals only with List
then it will work for any class that implements List
(e.g. LinkedList
, etc). But, if your code directly deals with ArrayList
then it's limited to ArrayList
.
CharSequence s = new String("String");
Manually instantiating a String
object is not good. You should use string literal instead. I am just guessing the reason that you don't see CharSequence
might because it's quite new and also, strings are immutable.