How to create a mixed data buffer in Java? -
i need create buffer contains byte , string data. how can in java?
you can use plain array of objects object[] or implementation of collections (list, set) etc.
but why? if want store different types of data in same collection, check design. if still wish create wrapper interface , many want implementations. each implementation store type if data. create collection stores these wrappers:
interface storagecell<t> { } class stringcell implements storagecell<string>{} class bytecell implements storagecell<byte>{}
and buffer is: collection<? extends storagecell> buffer = new linkedlist<storagecell>();
Comments
Post a Comment