About the trim of Java

Source: Internet
Author: User

One of the problems with the development of an Android project is this:

There is a checkbox multi-box in the configuration page of the program that shows whether a configuration module is displayed, after the following series of procedures: Select Module to display >> serialization save >> read out configuration >> display module according to configuration

The module shown is not the same as the configured content.

After a variety of guesses, output log and debug, finally found the problem:

One of the following is written:

Panelinfo panelinfo = new Panelinfo (Paneltitlelist[i],paneliconlist[i],panelclasslist[i],boolean.parseboolean ( Gridviewadapter.gChecked.get (i)));
We can see that the last parameter of Panelinfo converts a string to a Boolean type, and the content is found to contain a "space" after printing the conversion!!

If "true" is actually "true", it is converted directly to false! after conversion.

That should be the way it works.

Panelinfo panelinfo = new Panelinfo (Paneltitlelist[i],paneliconlist[i],panelclasslist[i],boolean.parseboolean ( Gridviewadapter.gChecked.get (i). Trim ()));

Note that the trim!! is added to the rear.

This problem has really been committed many times, sometimes really do not think, may wish to see if there is no trim brought about by the problem. Therefore, there is a need to be aware of type conversions.


Trim has the following effects:

Causes the string to remove the copy of the leading and trailing blanks, and returns this string if there is no leading and trailing whitespace

About the trim of Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.