compareTo(LongBuffer): This method is available in java.nio.LongBuffer class of Java.
Syntax:
int java.nio.LongBuffer.compareTo(LongBuffer that)
This method takes one argument of type LongBuffer as its parameter. This method compares this buffer to another.
Note: A long buffer is not comparable to any other type of object.
Parameters: One parameter is required for this method.
that: the object to be compared.
Returns: A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the given buffer
Approach
Java
import java.nio.LongBuffer;public class LongBuffercompareTo {public static void main(String[] args) {long array[] = { 1, 2, 3, 4 };LongBuffer lb = LongBuffer.wrap(array);long array2[] = { 1, 2, 4, 6 };LongBuffer that = LongBuffer.wrap(array2);System.out.println(lb.compareTo(that));}}
Output:
-1
No comments:
Post a Comment