Hi,
Please try to understand that ArrayList inherits from List. Most of the books will go with using
is nearly same as writing
. Now
is actually a non-benefit code.
You need to understand the reason for using Generics. Generics are used primarily to ensure Type Safety. Notice when you use the first and second statements you mention the data type(i.e. String) the list will be using hence preventing the list being accidentally used for some other types making it types safe...However the third definition is similar to writing
in which you can pass any types which is not at all type safe. I wish I have explained you. I am still learning
JAVA correct me if I am wrong..I will appreciate it.