#CodeSnippet - Reverse a byte array in android

Reverse a byte array using the following code

public static void reverse(byte[] reverseArray) {
        // if array is empty return null 
        if (reverseArray == null) {
            return;
        }
        
        //start index of array
        int i = 0;
        // get the length
        int j = reverseArray.length - 1;
        byte tmp; //for storing values for exchange purpose 
        while (j > i) {
            tmp = array[j];
            array[j] = array[i];
            array[i] = tmp;
            j--;
            i++;
        }
      }

Comments

Popular posts from this blog

Making Bootable Pendrive with .bat file

R-W-W (Real, Win, Worth it ) - Boost your idea

Ek Beej Tha Gaya Bahut Hee Gaharaee Mein Boya - Nanha Paudha