Friday, 13 November 2015

Java Tutorial : Java Unary Bitwise Complement Operator


Click here to watch in Youtube :
https://www.youtube.com/watch?v=h0F-gxUSHZ8&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Unary Bitwise Complement Operator
UnaryBitwiseComplementOperator.java
class UnaryBitwiseComplementOperator
{
    public static void main(String[] args)
    {

        /*
         * An integer type contains 32 bit information. 
         * 8 = 00000000000000000000000000001000
         */

        int number = 8;
        System.out.println("number = " + number);
        System.out.println(Integer.toBinaryString(number));

        /*
         * Using the ~ operator inverts the number by change the every "0" to
         * "1" and every "1" to "0"
         * 
         * 00000000000000000000000000001000 
         * 11111111111111111111111111110111
         */

        int invertedNumber = ~number;
        System.out.println("invertedNumber = " + invertedNumber);
        System.out.println(Integer.toBinaryString(invertedNumber));

    }
}
Output
number = 8
1000
invertedNumber = -9
11111111111111111111111111110111
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/OperatorsDemoComplementOperatorApp.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OperatorsDemoComplementOperatorApp

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/e1afee1d6e12479b500465256b2025d133889626/BasicJava/OperatorsDemoComplementOperatorApp/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment