简体   繁体   中英

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.

Now I performed this code. method1() returns a string; the string is checked on logcat and debug which has values.

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.

On logcat value screen string = "this is a gigantic string which probably exceeds over 500 characters".
On debug screen string = "this is a gigantic string which probably exceeds over 500 characters".

My approach on seeing data is on logcat is

Log.i("dataLegnth:", Integer.toString(dataLegnth));

Nothing shows on logcat or on value on debug mode for dataLegnth. I tried project clean as well. There are no errors on 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:

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.
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.

Otherwise, I don't understand what you are asking. Please be more specific.

一定要错过逻辑,因为我重写了代码,但效果很好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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