Character.reverseBytes() in Java

Character.reverseBytes(): This method is available in java.lang.Character class of Java.

Syntax:

char java.lang.Character.reverseBytes(char ch)

This method takes one argument of type char as its parameter. This method returns the value obtained by reversing the order of the bytes in the specified char value.

Parameters: One parameter is required for this method.

ch: The char of which to reverse the byte order.

Returns: the value obtained by reversing (or, equivalently, swapping)the bytes in the specified char value.

Exceptions: NA

Approach

Java

public class CharacterreverseBytes {
    public static void main(String[] args) {

        char ch = 'a';
        System.out.println(Character.reverseBytes(ch));
    }
}

Output:

No comments:

Post a Comment