Java bitwise operators

This is a code snippet found in android.widget.AutoCompleteTextView class:

        // Always turn on the auto complete input type flag, since it
        // makes no sense to use this widget without it.
        int inputType = getInputType();
        if ((inputType&EditorInfo.TYPE_MASK_CLASS)
                == EditorInfo.TYPE_CLASS_TEXT) {
            inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            setRawInputType(inputType);
        }

Here is what I found out: Java Notes: Bitwise Operators

System.out.println("3 & 7 = "+(3 & 7));//3
System.out.println("2 & 4 = "+(2 & 4));//0
System.out.println("2 & 5 = "+(2 & 5));//0
System.out.println("1 & 2 = "+(1 & 2));//0
System.out.println("1 & 0 = "+(1 & 0));//0

System.out.println("3 | 7 = "+(3 | 7));//7
System.out.println("2 | 4 = "+(2 | 4));//6
System.out.println("2 | 5 = "+(2 | 5));//7
System.out.println("1 | 2 = "+(1 | 2));//3
System.out.println("1 | 0 = "+(1 | 0));//1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: