If I have a treemap that contains string and double. Is there anyway to retrieve say first 10 keys from map?
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.
Fetch the iterator via
treeMap.entrySet().iterator()if you want the key/value pairs ortreeMap.keySet().iterator()if you just care about the keys, then calliterator.next()10 times or as long asiterator.hasNext()returnstrue.