What is reason behind supporting the syntax below on java 1.7
List<Integer> ints=new ArrayList<>();
What flexibility does it provide? If we wanted ints to be of a different type we would explicitly cast it and it would throw an error if the conversion could not be performed.
I am also not clear on how exactly does this work.Since List is an interface how are we able to call a method on it
List<Integer> ints = Arrays.asList(1,2);
ints.get(1);
Since return type of asList() is static<T> List<T> it's okay to access a field of a static interface without any class providing an implementation of it.But how are we able to access a method on such an interface
The collections library has a lot of them like Collections.Sort()
Who provides the implementation of these methods?
return type of asList() is static List?<>asks the compiler to fill in the type, if he can. Using nothing at all uses a raw type and is discouraged.