What is the need of collection framework in java? - Stack Overflow
how to understand Java Collection Frameworks ?
What are some of the most used data structures of Java Collections Framework? What are the things that a person should pay attention when learning Java Collections Framework?
any one know about the collection framework? did it relly used in java realtime projects in it company ?
Videos
- Arrays are not resizable.
- Java Collections Framework provides lots of different useful data types, such as linked lists (allows insertion anywhere in constant time), resizeable array lists (like
Vectorbut cooler), red-black trees, hash-based maps (likeHashtablebut cooler). - Java Collections Framework provides abstractions, so you can refer to a list as a
List, whether backed by an array list or a linked list; and you can refer to a map/dictionary as aMap, whether backed by a red-black tree or a hashtable.
In other words, Java Collections Framework allows you to use the right data structure, because one size does not fit all.
Several reasons:
- Java's collection classes provides a higher level interface than arrays.
- Arrays have a fixed size. Collections (see ArrayList) have a flexible size.
- Efficiently implementing a complicated data structures (e.g., hash tables) on top of raw arrays is a demanding task. The standard HashMap gives you that for free.
- There are different implementation you can choose from for the same set of services: ArrayList vs. LinkedList, HashMap vs. TreeMap, synchronized, etc.
- Finally, arrays allow covariance: setting an element of an array is not guaranteed to succeed due to typing errors that are detectable only at run time. Generics prevent this problem in arrays.
Take a look at this fragment that illustrates the covariance problem:
String[] strings = new String[10];
Object[] objects = strings;
objects[0] = new Date(); // <- ArrayStoreException: java.util.Date
in my Java backend learnings, I have created projects and learned Java, Spring Boot, JDBC, and many other things but I find it difficult to grasp Java collections, I have used it while using projects as needed, but I don't know anything, so how should I learn that I want to solve basic questions for interview purpose(definitely not competitive level just basic), any resource or ideas appreciated.
Hello. I am new to Java and am currently trying to learn about Java Collections Framework. I was curious what are data structures that are most commonly used and that everyone should know? I know that ArrayList and HashMap are popular, but are there any others? What are some important thing that someone learning Collections framework should know?