Say I have a LinkedHashMap containing 216 entries, how would I get the first 100 values (here, of type Object) from a LinkedHashMap<Integer, Object>.
Say I have a LinkedHashMap containing 216 entries, how would I get the first
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ugly One-Liner
This ugly one-liner would do (and return a
ArrayList<Object>in the question’s case):This would work for a
HashMapas well, howeverHashMapbeing backed by aHashSetthere’s not guarantee that you will get the first 100 values that were entered; it would work on other types, with similar limitations.Notes:
Step-By-Step Usage Example
(as per the OP’s comment)