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.

Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27

Thread: SIMPLE PROGRAMING PROBLEMS help!!

  1. #26
    Member
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: SIMPLE PROGRAMING PROBLEMS help!!

    True, but when you think about it &, |, &, and ~ (Does Java have bitwise-not?) is designed for numbers, not Booleans. A SIDE EFFECT of booleans being bytes makes it work on booleans like you would expect. So maybe we're both right? maybe it's not strictly both, if that makes sense?

  2. #27
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: SIMPLE PROGRAMING PROBLEMS help!!

    It is not (that's not) a Side Effect from the point of view of the Java language author and maintainers. It is defined behavior, as shown in the Java Language Specification. (My reference was from the Third Edition. If you are interested, you can download the edition appropriate for your version of Java here: Java SE Specifications)

    Here are the facts, as documented in the JLS:

    Integer Bitwise operators &, ^, and | were designed for operands that can be converted to primitive integer data types.
    Boolean Logical Operators &, ^, and | were designed for boolean (and Boolean) operands.

    If you don't want to use the boolean logical operators, '&' '^' and '|' that's OK. I mean, nobody will try to make you use something that you don't like, but they are part of the language. Deterministic behavior is defined and guaranteed. (Note that neither the JLS nor I said anything about a boolean '~' operator. There is no such thing defined for the Java language.)



    Cheers!

    Z
    Last edited by Zaphod_b; October 17th, 2012 at 12:17 PM.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Problems with GUI, seems simple fix but I can't figure it out
    By Harrald in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 31st, 2012, 04:51 AM
  2. Java programing help plz!
    By qazwsx in forum Java Theory & Questions
    Replies: 1
    Last Post: July 21st, 2012, 07:01 PM
  3. Programing
    By goha14 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 27th, 2012, 04:44 PM
  4. help with a programing assignment.
    By oscar_m in forum Object Oriented Programming
    Replies: 4
    Last Post: May 1st, 2011, 02:00 PM
  5. Im having problems compiling a very simple .js file to .exe
    By idesyl in forum Member Introductions
    Replies: 3
    Last Post: March 10th, 2011, 05:16 AM