Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8583
| From | bob <bob@coolgroups.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: optional operation |
| Date | 2011-10-05 14:20 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <6745899f-3c13-4d2b-81fb-52975c560a3b@q24g2000vby.googlegroups.com> (permalink) |
| References | <5eb0fcba-199f-46e4-b913-2f3e851d89fc@q26g2000vby.googlegroups.com> <c_idnaoeDvisCRHTnZ2dnUVZ_rWdnZ2d@earthlink.com> |
Thanks, but I am still confused. How can a buffer not be backed by an accessible array? I tried this code, and hasArray returns true. However, hasArray2 returns false. byte[] b = new byte[numfloats*4]; dis.read(b, 0, numfloats*4); ByteBuffer bb = ByteBuffer.wrap(b); boolean hasArray = bb.hasArray(); FloatBuffer fb2 = bb.asFloatBuffer(); boolean hasArray2 = fb2.hasArray(); I'm trying to get a float[] out of this, but I can't if hasArray2 returns false. On Oct 5, 12:30 pm, Patricia Shanahan <p...@acm.org> wrote: > On 10/5/2011 9:49 AM, bob wrote: > > > I'm looking at the docs for FloatBuffer, and in many places it says > > "(optional operation)". What's the deal with this? Can we use the > > operation or not? > > The term "optional operation" is used in interface and abstract class > declarations to indicate a method that the implementation may be allowed > to throw UnsupportedOperationException. > > There are two useful places to look for more information: > > 1. The full description of the method. For example, FloatBuffer's array > method is defined to throw UnsupportedOperationException "If this buffer > is not backed by an accessible array". > > 2. Especially in java.util, there are interfaces with many different > implementing classes, and you may need to look at the API documentation > for the implementing class you are using to find out which operations it > supports. > > Patricia
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
optional operation bob <bob@coolgroups.com> - 2011-10-05 09:49 -0700
Re: optional operation Patricia Shanahan <pats@acm.org> - 2011-10-05 10:30 -0700
Re: optional operation bob <bob@coolgroups.com> - 2011-10-05 14:20 -0700
Re: optional operation markspace <-@.> - 2011-10-05 15:51 -0700
Re: optional operation markspace <-@.> - 2011-10-05 16:05 -0700
Re: optional operation bob <bob@coolgroups.com> - 2011-10-05 23:46 -0700
Re: optional operation Lew <lewbloch@gmail.com> - 2011-10-06 06:47 -0700
csiph-web