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

Thread: check all purchase using methos equals without operator if

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

    Smile check all purchase using methos equals without operator if

    Hello
    How check all purchase using methos equals without operator if.

    I have next code:

     for(Purchase purchase : listShop)
    	    {
    	    	//output in console
    	    	System.out.println(purchase);
    	    	//found max cost purchase
    	    	if(purchase.getCost() > maxCost)
    	    	{
    	    		maxCost = purchase.getCost();
    	    	}
    	    	//check equals all purchase
    	    	if(equalResult)
    	    	{
    	    		equalResult = purchase.equals(listShop[0]);
    	    	}
     
    	    }
     
     
    	}

    How change without if: if(equalResult)
    {
    equalResult = purchase.equals(listShop[0]);
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: check all purchase using methos equals without operator if

    I have no idea what you're asking. Please see the link in my signature on asking questions the smart way, as well as this link: http://www.javaprogrammingforums.com...-get-help.html
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: check all purchase using methos equals without operator if

    i mean, how use this code without if

    if(equalResult)
    {
    equalResult = purchase.equals(listShop[0]);
    }

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: check all purchase using methos equals without operator if

    I don't know, because I don't know what that code is supposed to do. You have not posted any code that will compile, let alone run, so it's pretty hard to tell you a different way to do it.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: check all purchase using methos equals without operator if

    Sorry,

    its code:

     for(Purchase purchase : listShop)
    	    {
    	    	//output in console
    	    	System.out.println(purchase);
    	    	//found max cost purchase
    	    	if(purchase.getCost() > maxCost)
    	    	{
    	    		maxCost = purchase.getCost();
    	    	}
    	    	//check equals all purchase
    	    	if(equalResult)
    	    	{
    	    		equalResult = purchase.equals(listShop[0]);
    	    	}
     
    	    }

    How change

    if(equalResult)
    {
    equalResult = purchase.equals(listShop[0]);
    }

    but without operator if?

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: check all purchase using methos equals without operator if

    Sigh. That's just a repost of your original post, which I already told you wasn't enough. What is equalResult supposed to be? What is this code supposed to do? Did you read the links I gave you? Did you create an SSCCE like I asked?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Method Equals, Boolean...
    By boys8goods in forum Object Oriented Programming
    Replies: 1
    Last Post: June 25th, 2011, 03:34 PM
  2. string.equals(anotherString) Anything like this for doesn't equal?
    By Andyandhisboard in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 11th, 2011, 06:50 PM
  3. [SOLVED] Difference between == and equals.
    By goldest in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 18th, 2010, 03:15 PM
  4. main methos problem
    By bondage in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 1st, 2010, 02:43 AM
  5. Equals Method
    By Sninald in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 18th, 2010, 03:06 AM