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 3 of 3

Thread: Beginner Problem

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

    Default Beginner Problem

    Hi. I've just started learning java. Tried compiling and got this error "bad operand types for binary operator || "

    here's my code:



    if ((height = 0) || (width = 0)) {
    System.out.println("Invalid values");
    }
    else {
    System.out.println("Rectangle of width"+ width + "and height" + height + "is created");
    }

    Can't seem to figure out what's wrong.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Beginner Problem

    bad operand types for binary operator
    (height = 0)
    The above is an assignment (=) statement that returns whatever type height is. For example int
    The || operator requires boolean not int.
    Hint: the == operator returns a boolean.
    Last edited by Norm; August 15th, 2011 at 12:48 PM. Reason: correct spelling

  3. The Following User Says Thank You to Norm For This Useful Post:

    Melvrick (August 15th, 2011)

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

    Default Re: Beginner Problem

    I see. It works now. Thanks alot!! =)

Similar Threads

  1. Beginner Problem
    By jokibaer in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 15th, 2011, 06:34 PM
  2. ServletExample code problem - beginner
    By Sawubona in forum Java Servlet
    Replies: 5
    Last Post: July 4th, 2011, 05:57 AM
  3. Beginner method call problem
    By Lasda in forum Java Theory & Questions
    Replies: 2
    Last Post: May 10th, 2011, 03:31 PM
  4. Beginner Problem
    By nve5009 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 19th, 2010, 11:29 AM
  5. I need a help ! i am beginner
    By yinky in forum Java Theory & Questions
    Replies: 3
    Last Post: September 30th, 2009, 07:22 AM