Please help to complete this task.

Task 5, option 4.

Develop and simulate an algorithm for performing a given operation on a binary vector A. Present the corresponding fragment of a java-program.

Number of bytes in binary vector: 2

Swap the third and fourth tetrads

Closed due to the fact that the participants are not on the topic : , rjhdby , Senior Pomidor , Mikhail Vaysman , Igor 12 Feb '17 at 19:47 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - YuriyPb, rjhdby, Senior Pomidor, Mikhail Vaysman, Igor
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    Show the code that you have already written and tell that it does not work for you. Just like that, homework is not done here by fotam. You need to show that you have tried to do something yourself. Next, we will help you - YuriySPb
  • Gosh, it's good that you rewrote the task instead of a photo. But this does not change the essence of the problem. Please solve learning tasks yourself. ) - Nick Volynkin

1 answer 1

Revert, perhaps: http://ideone.com/4rgeEt .

import java.util.*; import java.lang.*; import java.io.*; class Ideone { public static void main (String[] args) throws java.lang.Exception { short x = (short)0xABCD; short y = (short)Integer.parseInt(String.format("%04x", x).replaceAll("(.)(.)(..$)", "$2$1$3"), 16); System.out.println(String.format("%04x", y)); } } 
  • I think you break his brain ... - elik
  • one
    @elik, but how else))) - Qwertiy