• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

question about API info on Sun's website

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com/j2se/1.4.2/docs/api/index.html
Most of the methods for File Channels and ByteBuffers are listed as abstract, but seem to be implemented. I find this confusing. Does anyone know what I mean? For example, the getInt() method for ByteBuffer is listed as abstract, but I've tried that method in my test program, and it works. Am I missing something or is the documentation just wrong?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that you don't create ByteBuffers using a constructor; you get them from the static allocate() and wrap() methods. The objects returned by these methods are not instances of ByteBuffer itself, but instances of subclasses of ByteBuffer. The same is true of virtually all of the other java.nio classes. ByteBuffer has abstract methods, but the subclasses actually implement those methods.
Methods like allocate() and wrap() are called abstract factory methods; they allow your code to work with one generic class interface while actually making use of different implementation classes for different situations.
 
pie. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic