• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to store a list of byte array(primitive)

 
Ranch Hand
Posts: 91
IntelliJ IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a function where the return type is a byte[] (primitive). This function will be called multiple times and I need to store an list of byte[] (primitive type). I tried using Guava's but then it get's converted into Java object and then I am able to get it as a byte and not a byte array. E.G.
I hope the question is clear. Basically, how can I store a list of byte[] as primitive and then use it at a later point in time.
 
Marshal
Posts: 79508
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A byte might be a primitive but a byte[] isn't. What about a List<byte[]>?
Remember the usual rules about memory capacity, etc., will apply.
 
Vineeth Menon
Ranch Hand
Posts: 91
IntelliJ IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbell,

Thanks a lot for your reply. I was quite amazed to know that byte[] is not a primitive. So, how will a List<byte[]> be considered as an object? Is that how Java treats in internally? I'm quite fascinated.
 
Campbell Ritchie
Marshal
Posts: 79508
379
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All arrays are objects implicitly, not primitives. Look in the Java® Language Specification (=JLS). This is the link to §4.3 telling you what the different kinds of reference types are. You can add all kinds of reference type to a List, as long as the appropriate <E> type is used.
reply
    Bookmark Topic Watch Topic
  • New Topic