import java.nio.CharBuffer; public class CharBufferDemo { public static void main(String[] args) { CharBuffer charbuffer1 = CharBuffer.allocate(6); CharBuffer charbuffer2 = CharBuffer.allocate(6); charbuffer1.put('B').put('U').put('F').put('F').put('E').put('R'); charbuffer2.put('B').put('U').put('F').put('F').put('E').put('R'); if (charbuffer1.limit(5).equals(charbuffer2.limit(5))) System.out.println("true"); else System.out.println("false"); } }