What is the need for a Java collection structure, since all data operations (sorting / adding / deleting) are possible using arrays, and in addition, the array is suitable for memory consumption, and performance is also better than collections.
Can someone point me to a real-time data-oriented example that shows the difference in both (array / collections) of these implementations.
Vector
Hashtable
List
Map
, Java Collections Framework , .
:
, :
String[] strings = new String[10]; Object[] objects = strings; objects[0] = new Date(); // <- ArrayStoreException: java.util.Date
, Set, List Map, " ". / .
API . .
LinkedList: , . .
Set: , - O (N). HashSet O (1).
. , , .
. , :
, , /, , , Hash * . , .
, "", Java Dictionary, , ...
, , , . , List ( Set) Map .
, , List Set , . , " " .
, , , , . , , , , .
- .
, , , , , . ..
, /, , .length , . , , , . .
. , - LinkedList? , : http://en.wikipedia.org/wiki/List_of_data_structures
LinkedList
- Java, , , , , , , , , , , , , , , , . , ArrayList, .
- , , , , , LinkedList, , , , , . .
Java , .
, ARRAY , , , - .
, , :
.
- ./ ; (.. , ).
. , " ", .
Set - " " - , , , .
- , , . -;- , . " ", " ?", " ?" .
, , , , .
To learn more about Java collections, check out this article .