Please refer to the applications of hashing for details. Methods in HashMap K — The type of the keys in the map. V — The type of values mapped in the map. Methods inherited from class java. Methods inherited from interface java. This article is contributed by Vishal Garg. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.
See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Skip to content. Change Language. Related Articles. Basics of Java. Operators in Java. Packages in Java. Flow Control in Java. Loops in Java. Jump Statements in Java. Arrays in Java.
Strings in Java. OOPS in Java. Constructors in Java. Interfaces in Java. Keywords in Java. Exception Handling in Java. Interview Questions. Company Questions. Artificial Intelligence.
Cloud Computing. Data Science. Angular 7. Machine Learning. Data Structures. Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. Cyber Security. C Programming. Control System. Data Mining. Data Warehouse. Downvote, why? I think this is a proper question. Shows lack of knowlegde though, but on SO question should not be downvoted for showing lack of knowledge.
In fact a question is always a result of lack of knowledge. Add a comment. Active Oldest Votes. While you could use a map as a list, there are some definite downsides of doing so. Code readability Consider the following examples. Improve this answer.
LinkedLists are often said to be bad because of performance issues. I frequently use LinkedLists over ArrayLists because of element ordering. Would it be better for performance and memory if I used HashMaps with positions as keys?
I will put here some real case examples and scenarios when to use one or another, it might be of help for somebody else: HashMap When you have to use cache in your application. LinkedList When the order is important they are ordered as they were added to the LinkedList , the number of elements are unknown don't waste memory allocation and you require quick insertion time O 1.
Simon Walker Simon Walker 11 3 3 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Data Structures. Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. Cyber Security. C Programming. Control System. Data Mining. Data Warehouse. Javatpoint Services JavaTpoint offers too many high quality services.
Points to remember Java HashMap contains values based on the key. Java HashMap contains only unique keys.
0コメント