Question

I'm surprised to see duplicate "Android Lint Warnings" for the following code fragment:

122 String contactName = contact.getName();
123 name += contactName.substring(0, 1).toUpperCase();

-> Implicitly using the default local is common source of bugs: Use toUpperCase(Locale) instead; Contact.java; line 123
-> Implicitly using the default local is common source of bugs: Use toUpperCase(Locale) instead; Contact.java; line 123

I know how to fix this, but I'm still surprised to see the same warning twice. Anybody ideas/suggestions, or is this an Android_Lint_Warning-issue? My development setup: iMac, ADT/Eclipse Build: v22.2.1-833290

Was it helpful?

Solution

Found the solution, i.e. if you use the following code snippet you only get one warning:

122 String contactName = contact.getName();
123 name = name + contactName.substring(0, 1).toUpperCase();

-> Implicitly using the default local is common source of bugs: Use toUpperCase(Locale) instead; Contact.java; line 123

Also if you're using something like:

123 name = contactName.isEmpty() ? "-" : contactName.substring(0, 1).toUpperCase();

you'll get the same two warnings as mentioned before !?!

Probably has to do with building/parsing the expression tree IMHO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top