Solved

java equivalent of bcopy and bzero

Posted on 1997-04-04
1
1,262 Views
Last Modified: 2008-03-10
Is there a java equivalent to c++ bcopy and bzero functions?
It not, does anyone have any suggestions on how I should go
about implementing them?

Thanks for your help.
0
Comment
Question by:raihan
1 Comment
 
LVL 1

Accepted Solution

by:
JWBito earned 50 total points
ID: 1219423
Considering that bcopy and bzero allow one to write anywhere on the process address space, we are glad that Java does not provide the equivalent capability.

Whenever you create a new object, Java guarantees that it will have some initial value.  Primitive scalars (int, float and the like) are initialized to zero.  Booleans are false, and object references are null.

If you have a buffer that you need to move around, you might need to resort to System.arraycopy().  I would try to stay at a higher level and take advantage of Object.clone() for bcopy().  If you need to reinitialize something and are thinking of bzero, perhaps you should reconsider and try something similar to StringBuffer.setLength(0).  Of course, not all are allowed to be reinitialized.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
login form jsp example 2 49
How to convert from xls to xlsx using java 7 84
String array comparison 4 45
What browser will run Java? 7 122
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question