Help me Understanding Please...
Very new to java and was hoping someone could help clarify in specific detail the purpose of the following few lines of code:
bitset1.xor(bitset.get(30, 45));
number_users = intFromBits(bitset, 22, 8);
Thanks in advance for any guidance.
* confused *
Re: Help me Understanding Please...
bitset is a class and get is a method within the class. to call the get method from the class bitset, you use bitset.get()
bitset1 is a user created name for an instance(object) created from the bitset class. the object was probally created using: bitset bitset1 = new bitset(). You can create as many objects as you want as long as they each have a different name. You can even have an array of objects.
The last part gets a number from the data at a certain location in the object's data array and stores it in the variable number_users.
Re: Help me Understand Please...
Thank you for the explanation. Just a few more specific questions:
bitset1.xor(bitset.get(30,45)) --- Does that mean to compare through an exclusive or operation the total contents of bitset1 with only the contents of bitset from position 30 (inclusive) to position 45 (exclusive)? Is bitset1 then updated with a new value to reflect the outcome of the operation?
number_users = intFromBits(bitset, 22, 8) --- What location in the object's data array does this assign to the variable? If you could maybe provide sample data for the data array and what this operation would then assign to number_users that would be immensely helpful.
Thanks again...
Re: Help me Understanding Please...
One quick way to understand what code is doing is to write a program that executes it and look at the results.
Separate the code into separate method calls and print out the results for each call.
Write a sample program to do the steps, execute it, print out all the intermediate results and post it all here.
Re: Help me Understand Please...
Quote:
Originally Posted by
Jabetha
Thank you for the explanation. Just a few more specific questions:
bitset1.xor(bitset.get(30,45)) --- Does that mean to compare through an exclusive or operation the total contents of bitset1 with only the contents of bitset from position 30 (inclusive) to position 45 (exclusive)? Is bitset1 then updated with a new value to reflect the outcome of the operation?
number_users = intFromBits(bitset, 22, 8) --- What location in the object's data array does this assign to the variable? If you could maybe provide sample data for the data array and what this operation would then assign to number_users that would be immensely helpful.
Thanks again...
I have never used bitset so i am not sure. My answer was based on how java is designed, built and used.