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,352
  • 3
  • 28
  • 40
hakki
  • 6,181
  • 6
  • 62
  • 106

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
  • 114,292
  • 17
  • 138
  • 190
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
  • 28,470
  • 6
  • 53
  • 83