0

I try to use Math.reverseBytes in Java but giving error : The method reverseBytes() is undefined for the type Math

As you know it is static type . Why cant i use it?

import java.lang.Integer;

public class Test {
    public static void main(String[] args) {
        int x = Math.reverseBytes();//Eclipse cannot reach this function
    }
}

From Java Doc - Some Information

reverseBytes

public static int reverseBytes(int i);

Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified int value.

Returns: the value obtained by reversing the bytes in the specified int value.

Since: 1.5

Sean F
  • 2,333
  • 2
  • 25
  • 40
hakkikonu
  • 5,515
  • 6
  • 59
  • 105

2 Answers2

8

There IS no "Math.reverseBytes()".

Integer.reverseBytes() or Short.reverseBytes(), yes. Math - no.

PS:

You should definitely install JavaDoc in your Eclipse. Here's how:

Community
  • 1
  • 1
paulsm4
  • 107,438
  • 16
  • 129
  • 179
1

This method does not exist in Math package.
in your code you have imported java.lang.Integer, so did you mean

Integer.reverseBytes()

?

AlexWien
  • 27,900
  • 6
  • 50
  • 80