top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why can’t we write code as List<Number> numbers = new ArrayList<Integer>();?

0 votes
479 views
Why can’t we write code as List<Number> numbers = new ArrayList<Integer>();?
posted Mar 14, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

For this ans is having two step.
1. you can define the list and initialize it with arrayList of same type of object.
like List a= new ArrayLIst();
2. List or ArrayList or any other collection class is storing same type of object. They are creating space for that object. so due to the size of object we have to define and initialize with same type of object.

answer Mar 15, 2016 by Manoj Goswami
...