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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:19:18+00:00 2026-05-16T21:19:18+00:00

Currently the code below will give me a line by line listing of the

  • 0

Currently the code below will give me a line by line listing of the values, if i wanted to sum the values for one total, can someone give me an example of going about doing this?

if (value != null && !value.isEmpty()) {
    Set set = value.keySet();
    Object[] key = set.toArray();
    Arrays.sort(key);
    // System.out.println("test" + Arrays.asList(key));

    for (int i = 0; i < key.length; i++) {
        // System.out.println(value.get((String)key[i]))
        ArrayList list = (ArrayList) value.get((String) key[i]);

        if (list != null && !list.isEmpty()) {
            Iterator iter = list.iterator();
            double itemValue = 0;

            while (iter.hasNext()) {
                Iemunbuf p = (Itemunbuf) iter.next();

                if (p != null) {
                    propertyValue = itemValue + p.getitemValue().doubleValue();
                    System.out.println(itemValue);
                }

                // buf2.append(NL);
                buf2.append(t1 + "\t");
                // System.out.println(t1);
                buf2.append(NL);
            }

            buf1.append(NL);
            double amount = itemValue;
            buf1.append("  " + money.format(amount) + "  ");
        }
    }
}
  • 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-16T21:19:19+00:00Added an answer on May 16, 2026 at 9:19 pm

    Don’t know why you assign a value to amount just to print it – I suspect that what you mean to do was use amount as a grand total. Well it won’t work the way you have written as amount is declared inside your loop and so will always be initialized to 0.0 before you make the assignment – that and it is a flat out assignment and not summation. Declare amount outside the loop like Erick suggested then say amount += itemValue.

    Hope I understood your question properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently i obtain the below result from the following C# line of code when
I am currently publishing code behind .aspx in SharePoint. I can automatically publish the
I've put together a small code-sample below (Currently in C# 3.5 but would also
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
The code currently does this and the fgetpos does handle files larger than 4GB
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I currently have code in my ApplicationController to check if a user is logged
I'm currently refactoring code to replace Convert.To's to TryParse. I've come across the following
Here is the code currently used. public String getStringFromDoc(org.w3c.dom.Document doc) { try { DOMSource
Possible Duplicate: How do I get the HMODULE for the currently executing code? I'm

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.