简体   繁体   English

如何在Eclipse控制台(Java)中记录循环

[英]How to Log a Loop inside Eclipse Console (Java)

I am using Eclipse with Java and the Android SDK. 我将Eclipse与Java和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). 我有一个while循环,给我一些问题,我需要查看它在下面的if语句中所记录的内容(将什么内容添加到两个ArrayList中)。 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? 如何使用日志查看每次迭代中发生的情况?

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 假设i是你的迭代变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM