lukash
lukash

Reputation: 13

Correctness of the implementation of the list

i have a short question. For a very long time i implements ArrayList like this:

public ArrayList<Double> random = new ArrayList<Double>();

And no one correct me, so i thought it is good, but android studio underlines "Double" in 2nd ArrayList, but it works anyway

public ArrayList<Double> random = new ArrayList<>();

now Android studio do not show error, so what is the difference ?

Upvotes: 0

Views: 57

Answers (1)

Witold Kaczurba
Witold Kaczurba

Reputation: 10505

It should be no problem by Java standards. Android prefers what Oracle calls a diamond operator for type inference.

You may read more about it here: http://docs.oracle.com/javase/7/docs/technotes/guides/language/type-inference-generic-instance-creation.html There is also a long post about it on Stackoverflow: What is the point of the diamond operator in Java 7?

Upvotes: 1

Related Questions