[Testing] bug on a string type is not case-insensitive comparison to space and time

Java for equal comparisons should note the following points:

1. Consider using eqaulsIngoreCase ignore case

For attribute String name, it is generally used eqaulsIngoreCase when compared with the specific value, because different service English case input developers and users of the values ​​may not be rigorous, if equals rigorous judgment should lead to the original by the contrary is not passed, before use to ensure that String is not null, otherwise it throws a null pointer exception

2. Consider using trim spaces go to be relatively

Space is usually people who do not accidentally add, if not the passwords need to closely check can be open, it will be able to increase the pass rate, to use space stirng.trim () method, using this method need to make sure String is not null otherwise, throws null pointer exception

Guess you like

Origin www.cnblogs.com/ming-szu/p/10955615.html