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

Thread: Method Equals, Boolean...

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

    Default Method Equals, Boolean...

    got somebody can help me solve this problem if I want to put method equals that returns true if two objects contains the same information inside the item.java and change the status into boolean to represent status = eg:available or unavailable. thx alot...
    Last edited by boys8goods; June 25th, 2011 at 04:37 PM.


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

    Default Re: Method Equals, Boolean...

    I want to put method equals that returns true if two objects contains the same information inside the item.java
    Ok, what is your question about how to write an equals() method?
    The method needs to get a reference to another Item object and then compare each piece of information for for equality. If any are different you'd return false.

    change the status into boolean to represent status
    You currently have a variable name status that is a String. Is that what you are talking about?
    You could use the three-way operator to set status's value depending on boolean_exp:
    status = (boolean_exp ? "available" : "unavailable");

Similar Threads

  1. Need help with boolean method! =(
    By leao in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 14th, 2010, 10:18 AM
  2. Boolean method returning a boolean value
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 10:56 AM
  3. Method returning boolean
    By Plural in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2010, 06:45 PM
  4. Equals Method
    By Sninald in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 18th, 2010, 03:06 AM
  5. [SOLVED] Java exception "result already defined"
    By rptech in forum Object Oriented Programming
    Replies: 3
    Last Post: May 20th, 2009, 05:48 AM