• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

question about ByteBuffer

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused by the following code, any one help?

ByteBuffer bb = ByteBuffer.allocate(1024);
bb.asCharBuffer().put("Howdy!");
char c;
while((c = bb.getChar()) != 0)
System.out.print(c + " ");
System.out.println();

After calling to the bb.asCharBuffer().put("Howdy1") method, does the current position of ByteBuffer bb move to the end of "Howdy!"? From my understanding, in order to read "Howdy!" from the ByteBuffer, the rewind() method should be called first.

I run it and the abov code is ok. Why?
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is not in the scope of SCJP.
 
author
Posts: 9000
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Warren is correct.

In fact nothing from the java.nio package is included on any version of the SCJP exam.

hth,

Bert
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic