java/android int type How to empty?

Source: Internet
Author: User

/**implementation of the Textutils.isempty () method * Returns True if the string is null or 0-length.*@paramstr The string to be examined*@returntrue if STR is null or zero length*/     Public Static BooleanisEmpty (@Nullable charsequence str) {if(str = =NULL|| Str.length () = = 0)            return true; Else            return false; }

The default value for int is 0, and the default value for integer is null:

Java provides encapsulation classes for each primitive type, and integer is the wrapper class provided by Java for Int.
The default value for int is 0, and the default value for integer is null, that is, the difference between an unassigned and a value of 0 can be distinguished by an int, which cannot express an unassigned condition.

Simple Android int empty method:

int myInt = getInt (); if (Textutils.isempty (string.valueof (myInt))) {

The int of Java is sentenced to null:

int/ / getInt () may return empty!    if (null = = string.valueof (myInt) && "". Equals (string.valueof (myInt)) {    //}
Org.apache.commons.lang.StringUtils  ~ This package cannot be referenced by default in Android!
If (! Stringutils.isempty (string.valueof (myInt))) { else { }

java/android int type How to empty?

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.