Results 1 to 2 of 2
Thread: Error in Counter Code
- 07-12-2011, 04:10 PM #1
Member
- Join Date
- Jun 2011
- Location
- Louisville, KY
- Posts
- 6
- Rep Power
- 0
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:
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 :)Java Code:for(int x = 0; x < db.size(); x++) { comparisonScore = 0; for(int y = 0; y < compareList.size(); y++) { if(db.get(x).getAltTypes().contains(compareList.get(y))) { comparisonScore++; if((double)(comparisonScore / (db.get(x).getAltTypes().size())) > maxComparisonScore) { currentMatchLeader = db.get(x).getActualType(); maxComparisonScore = (double)(comparisonScore / (double)(db.get(x).getAltTypes().size())); } } } }
- 07-12-2011, 04:20 PM #2
Similar Threads
-
switch (counter) example please
By erin.ctm in forum New To JavaReplies: 1Last Post: 12-03-2010, 11:21 PM -
Increment Counter for ID
By blkshrk81 in forum New To JavaReplies: 6Last Post: 12-01-2010, 01:25 AM -
How to Add a Counter to a Variable?
By Bbob in forum New To JavaReplies: 22Last Post: 06-05-2010, 03:14 PM -
Counter
By ks1615 in forum New To JavaReplies: 6Last Post: 02-20-2009, 03:02 AM -
Frequency Counter
By justlearning in forum New To JavaReplies: 0Last Post: 05-07-2008, 10:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks