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

  • Home
  • SEARCH
  • 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 9124929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:40:52+00:00 2026-06-17T06:40:52+00:00

In the database, I have data in this format: The requirement is to represent

  • 0

In the database, I have data in this format:

enter image description here

The requirement is to represent the data in the excel in this format: The country name forms the tab name.

enter image description here

I was thinking to put every DB row in a object.. To achieve in the format, I need to iterate over the country list, then in each country list (e.g US), pick the list of States (NY, NY) and then within that loop iterate over the each state (e.g NY), so that you get New York and Alaby. Repeat this for other states & then come out of the loop & then iterate over other countries in the same fashion.

But the difficulty I am facing here is, how do I represent that data in Java which will allow me to iterate in the required format? So that when I Iterate over US, it gives me NY and NJ and when I iterate over NJ, it gives me cities within it. I am struck. Please advice some pointers to get me going

  • 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-17T06:40:54+00:00Added an answer on June 17, 2026 at 6:40 am

    Use a Map<String, Map<String, List<String>>>.

    1. The first String is the key of the country.
    2. The Map is a map where the key is the state and the value is the list of cities.

    Be sure to properly initialize the data before inserting your data. For example, here I insert “New York City” as an American city in the NY state:

    Map<String, Map<String, List<String>>> fullMap = new HashMap<String, Map<String, List<String>>>();
    fullMap.put("US", new HashMap<String, List<String>>());
    fullMap.get("US").put("NY", new ArrayList<String>());
    fullMap.get("US").get("NY").add("New York");
    

    To get the list of cities in (US, NY), you have to do :

    List<String> nyCities = map.get("US").get("NY");
    

    … which given our initialization process should return a list containing one item.

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

Sidebar

Related Questions

I have data in this format coming from a database... BUS 101S Business and
I have some data in the database, in this format: Description~Level||Description~Level|| I want to
I have a SQL database table column which has data in this format 0000-00-0000
Let's say i have a database design like this: for the data: id |
I have this code to update my SQL database from data in a textbox,
I have a datalogging application (c#/.net) that logs data to a SQLite database. This
I have data stored in the database with HTML format , and I want
I have sample data in this form: { ID:2 Type:None Reference1:6369-545.1 Reference2:6369-545.2 Name:John Smith
I want to get array format from mysql database. Example,Let I have name table
I have data stored as below in an MS Access database: Date User 20090101

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.