mismatch(IntBuffer): This method is available in java.nio.IntBuffer class of Java.
Syntax:
int java.nio.IntBuffer.mismatch(IntBuffer that)
This method takes one argument of type IntBuffer as its parameter. This method finds and returns the relative index of the first mismatch between this buffer and a given buffer.
Note: If the two buffers share a common prefix then the returned index is the length of the common prefix.
Parameters: One parameter is required for this method.
that: The byte buffer to be tested for a mismatch with this buffer.
Returns: The relative index of the first mismatch between this and the given buffer, otherwise -1 if no mismatch.
Exceptions: NA
Approach
Java
import java.nio.IntBuffer;public class IntBuffermismatch {public static void main(String[] args) {int array[] = { 1, 2, 3, 4 };IntBuffer lb = IntBuffer.wrap(array);int array2[] = { 1, 2, 4, 5 };IntBuffer that = IntBuffer.wrap(array2);System.out.println(lb.mismatch(that));}}
Output:
2
No comments:
Post a Comment