Search:

Type: Posts; User: akerman

Search: Search took 0.08 seconds.

  1. Replies
    9
    Views
    1,122

    Re: Summing values in hash table

    I found it in the map api for java... neverless I decided to use this function:


    double total = 0;
    for (Double value : voltages.values()) {
    total = total + value;

    Is there a...
  2. Replies
    9
    Views
    1,122

    Re: Summing values in hash table

    Well this is the example I found which might be useful but I wasn't able to adapt it:


    // Compute sum of salaries by department
    Map<Department, Integer> totalByDept = employees.stream()...
  3. Replies
    9
    Views
    1,122

    Re: Summing values in hash table

    .collect(Collectors.groupingBy(Employee::getDepartment,
    Collectors.summingInt(Employee::getSalary)));

    I was trying to use above example get the sum but I was not able to adapt it so it would work...
  4. Replies
    9
    Views
    1,122

    Re: Summing values in hash table

    I have seen a loop what it firstly takes the size and then calculates the sum. But I know there is an easier way using for loop... but could find an example which would help me.
  5. Replies
    9
    Views
    1,122

    Summing values in hash table

    Hi there;

    Just a simple question which has caused me problems.

    I created hashtable:


    private Map <String, Double> v = new ConcurrentHashMap<String, Double>();
Results 1 to 5 of 5