[英]Strange event using String.length on eclipse
I have a string which has a value I tested and saw on debug on values and on logcat. 我有一个字符串,其值经过测试,并在调试值和logcat时看到。
Now I performed this code. 现在,我执行了这段代码。 method1() returns a string;
method1()返回一个字符串; the string is checked on logcat and debug which has values.
在logcat上检查字符串,并调试包含值的字符串。
String string = method1();
int datalegnth = string.length();
Now on logcat and debug value column "dataLegnth" it is not even listed nor does it show a value. 现在,在logcat和调试值列“ dataLegnth”上甚至没有列出该列,也不显示任何值。
On logcat value screen string = "this is a gigantic string which probably exceeds over 500 characters". 在logcat值屏幕上,字符串=“这是一个巨大的字符串,可能超过500个字符”。
On debug screen string = "this is a gigantic string which probably exceeds over 500 characters". 在调试屏幕上,字符串=“这是一个巨大的字符串,可能超过500个字符”。
My approach on seeing data is on logcat is 我在logcat上查看数据的方法是
Log.i("dataLegnth:", Integer.toString(dataLegnth));
Nothing shows on logcat or on value on debug mode for dataLegnth. 在logcat上或dataLegnth的调试模式下的值均未显示。 I tried project clean as well.
我也尝试过清洁项目。 There are no errors on logcat.
logcat上没有错误。
Has anyone encountered a problem similar to this or does anyone have a solution? 有没有人遇到与此类似的问题或有解决方案?
Well if you want dataLength
on your LogCat, just add this somewhere: 好吧,如果您想在LogCat上使用
dataLength
,只需将其添加到以下位置:
Log.d(null, "Value of dataLength: " + dataLength);
When you execute your program, the LogCat should read "Value of dataLength: (some value)" wherever you implemented the code. 当您执行程序时,无论在哪里实现代码,LogCat都应显示“ dataLength的值:(某些值)”。
If the LogCat reads "Value of dataLength:" when you execute your program however, dataLength is probably null and something is not right in your code. 但是,如果在执行程序时LogCat读取“ dataLength的值:”,则dataLength可能为null,并且代码中不正确。
Otherwise, I don't understand what you are asking. 否则,我不明白您的要求。 Please be more specific.
请更具体。
一定要错过逻辑,因为我重写了代码,但效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.