fork download
  1.  
  2. /* Name of the class has to be "Main" only if the class is public. */
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. byte[] arr = {5, 10, 100, -10};
  8. revers(arr);
  9.  
  10. }
  11.  
  12. public static void revers (byte[] args)
  13. {
  14. for(int i=0; i<args.length; i++) {
  15. int tmp = (int)args[i];
  16. tmp = ((tmp & 0x55) << 1) | ((tmp >> 1) & 0x55);
  17. tmp = ((tmp & 0x33) << 2) | ((tmp >> 2) & 0x33);
  18. tmp = ((tmp & 0x0F) << 4) | ((tmp >> 4) & 0x0F);
  19. System.out.format("# %d Byte revers to %d\n",args[i],(byte)tmp);
  20. args[i] = (byte)tmp;
  21. }
  22. }
  23.  
  24. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
# 5 Byte revers to -96
# 10 Byte revers to 80
# 100 Byte revers to 38
# -10 Byte revers to 111