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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:30+00:00 2026-06-10T11:40:30+00:00

I define a Map , and deposited inside objects, I would like to modify

  • 0

I define a Map , and deposited inside objects, I would like to modify the keys inside, the value of the how to modify?
Code is as follows:

package maptest;

/**
 * test Map
 * 
 * @author admin
 *@version 2012.8.29
 */

public class TestA {

private String name;
private String password;
private String idnum;

// name.
public void setName(String name) {
    this.name = name;
}

public String getName() {
    return name;
}

// password

public void setPassword(String password) {
    this.password = password;
}

public String getPassword() {
    return password;
}

// idnum

public void setIdnum(String idnum) {
    this.idnum = idnum;
}

public String getIdnum() {
    return idnum;
}

}

===========================================================

    package maptest;

import java.util.HashMap;
import java.util.Map;

/**
 * Test Map
 * 
 * @author admin
 *@version 2012.8.29
 */

public class TestB {

Map<Object, Object> map = new HashMap<Object, Object>();// map.

public void show() {
    TestA tes = new TestA();
    tes.setName("a");// name
    tes.setPassword("a123");// password
    tes.setIdnum("01");// idnum

    map.put(tes, tes);// add map.

    TestA tes1 = new TestA();

    tes1.setName("b");// name
    tes1.setPassword("a1234");// password
    tes1.setIdnum("02");// idnum

    /*
     * Assuming in accordance setIdnum ("02"), how to delete the name and
     * password of it belongs to?
     */

    map.put(tes1, tes1);// add map.

    TestA tes2 = new TestA();

    tes2.setName("c");// name
    tes2.setPassword("a12345");// password
    tes2.setIdnum("03");

    /*
     * Assuming in accordance setIdnum ("03") to find the name and password,
     * and then modify one of the password, concrete should be how to
     * achieve?
     */

    map.put(tes2, tes2);// add map.
}

public void showmap() {// show map
    for (Object c : map.keySet()) {
        System.out.println("Name>>>:" + ((TestA) map.get(c)).getName());
        System.out.println("Password>>>:"
                + ((TestA) map.get(c)).getPassword());
        System.out.println("Idnum>>>:" + ((TestA) map.get(c)).getIdnum());
        System.out.println("---------------------");
    }
    System.out.println("end.");
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    TestB te = new TestB();
    te.show();
    te.showmap();
}

}

==========================================

List and Set delete and modify and Map?

  • 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-10T11:40:32+00:00Added an answer on June 10, 2026 at 11:40 am

    You can make use of

    map.keySet().remove(obj);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to define a generic function for printing contents of std::map like types.
When we define routes in routes.rb using the name like map.some_link .We can use
I've got this snippet of code: (define-key lisp-interaction-mode-map (kbd C-c C-e) (lambda () (let
I am trying to define a mapping for Ctrl + . as follows: map
I would like to achieve something similar to how scala defines Map as both
I want to define a std::map with key as std::pair<std::string, std::string> something like follow
I cannot find the way to define a MongoRecord with a Map[String,String] field inside
I'm trying to define a vi 'map' command sequence, that would wrap the current
On REPL, if I define (def fits (map vector (take 10 (iterate inc 0))))
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is

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.