asCharBuffer(): This method is available in java.nio.ByteBuffer class of Java.
Syntax:
CharBuffer java.nio.ByteBuffer.asCharBuffer()
This method creates a view of this byte buffer as a char buffer. The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
Parameters: NA
Returns: A new char buffer
Approach
Java
import java.nio.ByteBuffer;public class ByteBufferasCharBuffer {public static void main(String[] args) {byte array[] = { 1, 2, 3, 4 };ByteBuffer bb = ByteBuffer.wrap(array);System.out.println(bb.asCharBuffer());}}
Output:
Ă̄
No comments:
Post a Comment