• Post Reply Bookmark Topic Watch Topic
  • New Topic

sizeof byte array  RSS feed

 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since Java doesn't support the sizeof() function like C/C++ is there another way to determine the number of bytes in a byte array?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um... array.length plus a little overhead? I suppose I'm misunderstanding the question.
- Peter
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are concerned with just the data, then array.length will do just fine. You don't have to worry about overhead. In fact, all arrays in Java have a length "member field" that gives the number of elements in the array.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!