Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Help me Understanding Please...

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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 *


  2. #2
    Member
    Join Date
    Aug 2011
    Posts
    86
    My Mood
    Lurking
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,247
    Thanks
    52
    Thanked 2,299 Times in 2,270 Posts

    Default 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.

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    86
    My Mood
    Lurking
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Default Re: Help me Understand Please...

    Quote Originally Posted by Jabetha View Post
    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.

Similar Threads

  1. HashMap : Simple Usage and Understanding
    By weakprogrammer in forum Collections and Generics
    Replies: 1
    Last Post: June 25th, 2011, 03:37 PM
  2. [SOLVED] Help with understanding the following commented codes!
    By u-will-neva-no in forum Java Theory & Questions
    Replies: 2
    Last Post: April 2nd, 2011, 04:26 PM
  3. Need help understanding method calls and such
    By hackman2007 in forum Java Theory & Questions
    Replies: 8
    Last Post: July 14th, 2010, 08:18 AM
  4. Need help understanding GUI screen layouts and labels
    By Bill_H in forum AWT / Java Swing
    Replies: 3
    Last Post: December 2nd, 2009, 10:50 PM
  5. Help understanding this code
    By Zepx in forum Java Theory & Questions
    Replies: 2
    Last Post: October 20th, 2009, 10:18 AM