Results 1 to 2 of 2
  1. #1
    DragonGhola is offline Member
    Join Date
    Jun 2011
    Louisville, KY
    Rep Power

    Default Error in Counter Code

    Hi there! I'm a fairly advanced Java user, but figured that this specific question should go here. My issue is that some counter code I'm using to do a 'matching' algorithm is giving me counter numbers which are much higher than the length of the ArrayLists that they are counting. Here is the relevant code:
    Java Code:
    for(int x = 0; x < db.size(); x++)
                    comparisonScore = 0;
                    for(int y = 0; y < compareList.size(); y++)
                            if((double)(comparisonScore / (db.get(x).getAltTypes().size())) > maxComparisonScore)
                                currentMatchLeader = db.get(x).getActualType();
                                maxComparisonScore = (double)(comparisonScore / (double)(db.get(x).getAltTypes().size()));
    db and compareList are ArrayLists, db.get(x).getAltTypes() returns an ArrayList, and db.get(x).getActualType() returns a String. My issue is that when I run this I get outputs of somewhere in the range of 868 for the maxComparisonScore, and it feels like I shouldn't be getting more than 1.0. Does anyone see the error here? Thanks for any help you can provide :)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    I get outputs of somewhere in the range of 868 for the maxComparisonScore
    Try debugging your code by Adding some printlns to show the values of the terms used to compute that value.

Similar Threads

  1. switch (counter) example please
    By erin.ctm in forum New To Java
    Replies: 1
    Last Post: 12-04-2010, 12:21 AM
  2. Increment Counter for ID
    By blkshrk81 in forum New To Java
    Replies: 6
    Last Post: 12-01-2010, 02:25 AM
  3. How to Add a Counter to a Variable?
    By Bbob in forum New To Java
    Replies: 22
    Last Post: 06-05-2010, 04:14 PM
  4. Counter
    By ks1615 in forum New To Java
    Replies: 6
    Last Post: 02-20-2009, 04:02 AM
  5. Frequency Counter
    By justlearning in forum New To Java
    Replies: 0
    Last Post: 05-07-2008, 11:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts