Title | CS Unit 5 DQ - learning journal |
---|---|
Author | Anonymous User |
Course | Programming 2 |
Institution | University of the People |
Pages | 1 |
File Size | 67 KB |
File Type | |
Total Downloads | 55 |
Total Views | 151 |
learning journal...
When writing a data structure, what should be our guidelines for choosing the right Java Collection? “The collection of data structure classes and interfaces is referred to as the Java Collection Framework, or JFC. (Eck, 2018)” Choosing the right Java Collection can be daunting especially for beginner who is just getting familiar to Java Collection. Like when should I use TreeSet or HashSet, or should I use TreeMap or HashMap, trust me I even have problem trying to choose which to use when writing a code example for them. According to (Javamex, nd) basic approach to choosing a collection:
Choose the general type of organisation that your data needs to have (e.g. map or list); without too much thought, this is usually fairly clear; Then, choose the implementation of that type that has the minimum functionality that you actually require (e.g. don't choose a sorted structure if you don't actually need the data to be sorted).
I will always follow this basic approach when I want to choose a Java Collection, according to (Eck, 2018) on which Java Collection framework to choose when working with Map “One should use a HashMap unless you have some particular need for ordering property of a TreeMap.”
REFERENCE How to choose which Java collection class to use? (n.d.). Retrieved October 05, 2020, from https://www.javamex.com/tutorials/collections/how_to_choose.shtml Eck, D. J. (2018). Introduction to programming using Java, Version 8. United States: Lulu....