0

I am using Eclipse with Java and the Android SDK.

I have a while loop giving me issues and I need to see what it being logged in the if statement below (what is being added to the two ArrayLists). This is the loop:

 while (totalDebt > 0) {

 // stuff

 if (totalDebt > 0) {
    debtList.add(totalDebt);
    feeList.add(interestFeeTotal);
 }

}

How can I use log to see what is going on here in each iteration?

TheLettuceMaster
  • 15,594
  • 48
  • 153
  • 259

1 Answers1

3

AT the top of your file you need to put

import android.util.log;

Then anywhere in that file you can write

Log.d("Tag","Message");

Where for message you can do something like

Log.d("Tag", String.format("Iteration(%d), added to the debtList", i);

assuming i is your iteration variable

Dan F
  • 17,654
  • 5
  • 72
  • 110
  • Hey thanks; I actually re-edited my answer. I stupidly didn't show the whole loop, and (doh!) it was a while loop... can you do the same with a while loop since it doesn't have an iteration variable? – TheLettuceMaster May 18 '12 at 17:21
  • 1
    Yeah, you can do the same, just print something like `Log.d("Tag", String.format("Current total debt: %f", totalDebt));` – Dan F May 18 '12 at 17:22