Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the List class

 
Vidhya Ramaswamy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we know, List is an interface. So, which class does Arrays.asList() return exactly?

 
Rajasekar Elango
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This blog might help you..

- Rajasekar
[ December 10, 2007: Message edited by: Rajasekar Elango ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter. All you know is that whatever the class is, it implements the List interface.
 
Vidhya Ramaswamy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rajasekar, that was helpful.

No wonder, the changes(using set()) made to the List view that is returned from Arrays.asList() is reflected in the original array.

But, if a new ArrayList object if created from Arrays.asList() :

and changes are made to this(using set()), it is not reflected in the original array.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic