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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:45:37+00:00 2026-05-20T01:45:37+00:00

I am trying to implement the use of two HashMaps and it seems to

  • 0

I am trying to implement the use of two HashMaps and it seems to be more or less successful also.But now my problem is i want to update the value of a hashMap based on a check.ie if userId is already existing in the hash i need to update the timestamp corresponding to it…

Below given is my code.How can we accomplish the updation of values .Can that be done usiong setValue..?but how..?please help me friends..

public static void main(String[] args)
{
  HashMap sessionTimeStampHash = new HashMap<Long, Long>(); //sessionID is the key and timeStamp is the value
  //userID is the key and sessionTimeStampHash object is the value
  HashMap<String, HashMap<Long, Long>> userSessionHash = new HashMap<String, HashMap<Long, Long>>();

  sessionTimeStampHash.put("sessionID", "timeStamp");
  userSessionHash.put("userID", sessionTimeStampHash);
  // System.out.println(userSessionHash);
  sessionTimeStampHash = new HashMap();

  sessionTimeStampHash.put("sessionID1", "timeStamp1");
  userSessionHash.put("userID1", sessionTimeStampHash);
  //  System.out.println(userSessionHash);
  sessionTimeStampHash = new HashMap();
  sessionTimeStampHash.put("sessionID2", "timeStamp2");
  userSessionHash.put("userID2", sessionTimeStampHash);
  //   System.out.println(userSessionHash);
  sessionTimeStampHash = new HashMap();
  sessionTimeStampHash.put("sessionID3", "timeStamp3");
  userSessionHash.put("userID3", sessionTimeStampHash);
  //   System.out.println(userSessionHash);


  for (Entry<String, HashMap<Long, Long>> entry : userSessionHash.entrySet())
  {
    String key = entry.getKey();
    System.out.println(key);
    System.out.println(entry.getValue());
    String userId = "userID3";
    if (key.equals(userId))
    {
      System.out.println("Check Successful");
      String TimeStamp = newTime;
      entry.setValue() // how can i change my timeStamp
    }
  }
}
  • 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-05-20T01:45:37+00:00Added an answer on May 20, 2026 at 1:45 am

    You can do without for loop

    if(userSessionHash.get(userId)!=null)
      userSessionHash.get(userId).put(userSessionHash.get(userId).keySet().toArray[0], timestamp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a custom comparer on two lists of strings and use
I've been trying to implement an online judge, but I'm stuck.. I use fork
For two weeks now I've been trying to implement Git at our office. Rather
I'm trying to implement solr to use the spatial searches to find the distance
I am trying to implement web services that use different security mechanisms to do
General use case I am trying to implement a basic shell. Description I need
Hi I am trying to use C to implement a simple struct: 2 boxes,
I'm trying to use a 3d texture in opengl to implement volume rendering. Each
I am trying to use django-social-auth to implement google openid login into my app,
I am trying to use the Soundcloud API to implement an integrated export function

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.