Chapter 20 Java Utilities Package and Bit Manipulation (Free web servers)

Chapter 20 Java Utilities Package and Bit Manipulation 1181 66 // perform bitwise AND and display results 67 public void actionPerformed( ActionEvent event ) 68 { 69 setFields(); 70 resultField.setText( 71 Integer.toString( value1 & value2 ) ); 72 bits3Field.setText( getBits( value1 & value2 ) ); 73 } 74 } 75 ); 76 77 buttonPanel.add( andButton ); 78 79 // button to perform bitwise inclusive OR 80 JButton inclusiveOrButton = new JButton( “Inclusive OR” ); 81 82 inclusiveOrButton.addActionListener( 83 84 new ActionListener() { 85 86 // perform bitwise inclusive OR and display results 87 public void actionPerformed( ActionEvent event ) 88 { 89 setFields(); 90 resultField.setText( 91 Integer.toString( value1 | value2 ) ); 92 bits3Field.setText( getBits( value1 | value2 ) ); 93 } 94 } 95 ); 96 97 buttonPanel.add( inclusiveOrButton ); 98 99 // button to perform bitwise exclusive OR 100 JButton exclusiveOrButton = new JButton( “Exclusive OR” ); 101 102 exclusiveOrButton.addActionListener( 103 104 new ActionListener() { 105 106 // perform bitwise exclusive OR and display results 107 public void actionPerformed( ActionEvent event ) 108 { 109 setFields(); 110 resultField.setText( 111 Integer.toString( value1 ^ value2 ) ); 112 bits3Field.setText( getBits( value1 ^ value2 ) ); 113 } 114 } 115 ); 116 117 buttonPanel.add( exclusiveOrButton ); Fig. 20.8Demonstrating the bitwise AND, bitwise inclusive OR, bitwise exclusive OR Fig. 20.8 and bitwise complement operators (part 3 of 6).
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply