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 8427337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:45:28+00:00 2026-06-10T04:45:28+00:00

So i have the following code which is an array of python dictionaries userInfo.append({userType:blah,

  • 0

So i have the following code which is an array of python dictionaries

userInfo.append({"userType":"blah",
         "userFN":"blah", 
         "userLN": "blah", 
         "userEmail":"blah@blah.com"})

I want to convert it to Java, right now the way I understand is best is to make a Map, and then create collections for it. Now I did the syntax but I am not sure if that is the best way

Map <String,String> userMap = new HashMap<String,String>();
HashSet<Map<String, String>> userMaps = new HashSet<Map<String,String>>();
...
userMap.put ("userType", "blah");
userMap.put("userFN", "blah");
userMap.put("userLN", "blah");
userMap.put("userEmail", "blah");
userMaps.add(userMap);

Is this the best way to do it?
Note: I haven’t ran this code because I am converting a decent chunk of code and want to convert as much as I can before debugging.

  • 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-10T04:45:29+00:00Added an answer on June 10, 2026 at 4:45 am

    Firstly, if you’re going to use Java, you ought to take advantage of the fact that it’s statically typed. Unless your user object is going to full of arbitrary properties, it’s a good idea to make a class for it.

    public class User {
      private String firstName;
      private String lastName;
      // etc.
    
      public User(String firstName, String lastName /*etc.*/){
        this.firstName = firstName;
        this.lastName = lastName;
        // etc.
      }
    }
    

    Also, your userInfo is probably an array, so use an ArrayList instead of a Set.

    ArrayList<User> userInfo = new ArrayList<User>();
    userInfo.add( new User("Some", "Guy" /*...*/) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which fetches a string from an array of strings
I have the following code which uses an array to write the result to
I have the following code which encodes json in php $arr = array('htmlOutput' =>
I have the following Python code which I am using to plot a filled
I have the following code which return wmi information (unknown array) For Each objMgmt
i have the following code which is meant to be looping over an array,
How is an array saved to NSUserDefaults? I have the following code which tries
I have the following code which uses one of the JTextAreas from an array
I have the following code of which I want to echo array elements separated
I have following code which works for radio buttons but need to be changed

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.