Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7930373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:24:02+00:00 2026-06-03T20:24:02+00:00

Code: Iterator<String> termIncomeKeys = termIncome.keySet().iterator(); while(termIncomeKeys.hasNext()){ String month = termIncomeKeys.next(); System.out.println(month); } The month

  • 0

Code:

    Iterator<String> termIncomeKeys = termIncome.keySet().iterator();
    while(termIncomeKeys.hasNext()){
        String month = termIncomeKeys.next();
        System.out.println(month);
    }

The month is printed as

Jan(2012) – Jan(2012)

Feb(2012) – Mar(2012)

Apr(2012) – May(2012)

Jun(2012) – Jun(2012)

Jul(2012) – Oct(2012)

What I want to achieve is I want to print the duration in terms of months between each of the entries. That is, Duration between first entry is 1 month, duration between second is 2 and so on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:24:03+00:00Added an answer on June 3, 2026 at 8:24 pm

    I do not know if there is a ready-made class that could parse these strings for you, but the logic is simple:

    convert the three-letter months to numbers (e.g. 0-11), and convert the years to numbers as well.
    The difference is <year-diff>*12 + <month-diff>, where <month-diff> might be negative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across the following code: for(Iterator<String> iterator = stuff.iterator(); iterator.hasNext();) { ...
I am having problems while listing an ArrayList. My code: Iterator<String> iterator = (Iterator<String>)
I have this simple code public String toString() { **Iterator it = list.iterator();** String
I have this code: FVDTO.setStatus(fail); List<String[]> invalidFields = new ArrayList<String[]>(); Iterator<ConstraintViolation<HazardSubmission>> iterator = cv.iterator();
Given such a code segment: #include <iostream> #include <iterator> #include <fstream> #include <string> using
I have this loop for (it= someCollection.iterator; it.hasNext(); ) { //some code here }
in the following code: int utf8len(char* s, int len) { Glib::ustring::iterator p( string::iterator(s) );
Why does this code result in a run-time error vector iterator not incrementable? vector<string>
In Java, when you iterator over a Vector<String[]> , why is .next() an Object
I have the following code: LinkedHashMap<String,ArrayList<String>> h; Set set = h.entrySet(); Iterator i =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.