1. Sort the bitwise operations, especially the left and right shifts (with or without symbols) to your blog.
The emphasis is on the operation process of clear negative numbers.
A: The shift operation for bytes in Java is divided by the direction of the left and right shifts, where the right movement is divided into signed right shift and unsigned right shift.
1. Signed right shift: Move the binary to the right if the original sign bit is 0 then the new sign bit also uses 0 otherwise 1;
2. Unsigned right shift: Move the binary to the right regardless of the original sign bit is 0 or 1 will be used 0 complement;
In addition, for the shift operation of the numeric value, each move to the right represents a single expression except two, moving left one represents multiply by two.
2.byte to hexadecimal string representation programming principles and implementation methods are organized into blogs.
public class Main {/** * byte type is in hexadecimal notation * @param args */public static void Main (string[] args) {char[] chars = {' 0 ', ' 1 ', ' 2 ' , ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F '};int i = 3; StringBuffer buffer = new StringBuffer (), byte B = 100;buffer.append (chars[(b>>4) & 0x0F]), Buffer.append (chars [B & 0x0F]); SYSTEM.OUT.PRINTLN (buffer);}}
3. Define a function to calculate the and of all elements of an integer array.
public class Main {/** * byte type is in hexadecimal notation * @param args */public static void Main (string[] args) {int sum =0; int[] n = new I nt[10];for (int i =0;i< 10;i++) {N[i] = i;} for (int j = 0;j<10; j + +) {sum+=n[j];} System.out.println ("The and of the one-dimensional array is:" +sum);}}
4. Copying of arrays
Package Homework;public class Main {public static void main (string[] args) {int[] array1 = new int[10];int[] Array2 = new int[10];//initialize array for (int i = 0;i<array1.length;i++) {Array1[i] = i;} Array2=arraycopy (Array1,array2); System.out.println ("copied array array2:"); for (int i:array2) {System.out.print (i);}} Array copy public static int[] ArrayCopy (int[] array1,int[]array2) {for (int i = 0;i<array1.length;i++) {Array2[i] = array1[ I];} return array2;}}
Big Data Fourth day job