Search:

Type: Posts; User: ober0330

Search: Search took 0.07 seconds.

  1. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Yeah. Not worth it for this instance. If it would be something different, it might be worth exploring.
  2. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Well yeah, so maybe what I'm looking for is a map that is extended for this purpose.

    You'd get a error if you tried to pass in a non-string... not sure what you're getting at?
  3. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Take the new value, add it to the existing value for the provided key.
  4. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Well yeah, I understand how the map works. I guess what I want is:

    mymap.add("key", value);

    And that doesn't seem to exist. And I guess it makes sense that it wouldn't be there by default...
  5. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Well, it obviously has many methods, but it doesn't seem to have another method for adding a value to an existing key. I guess I could use put to add the existing value of that key to the new value...
  6. Replies
    12
    Views
    5,254

    Re: Adding value to existing map key

    Nevermind. I think I'm over-complicating it because now I have to check to see if the key exists or not... gah. Not worth it.
  7. Replies
    12
    Views
    5,254

    Adding value to existing map key

    So I have a map:

    Map<String, Integer> totals = new LinkedHashMap<String, Integer>();

    I'm going to have about 6 running totals and I figured rather than creating 6 different variables, why not...
Results 1 to 7 of 7