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: Using the .equals method

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

    Default Using the .equals method

    I don't understand why when I run my program any strings with spaces in them are not considered equal. for example:
    when I run my program and enter "shih tzu" it does not equal this statement:

    newBreed.toLowerCase().equals("shih tzu")

    Is there some type of discrepancy for strings with spaces in them? It works for all of my conditions without spaces in the string.


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

    Default Re: Using the .equals method

    I ran a test and found that it does cut off my data entry after the first word, but why does it do this?

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

    Default Re: Using the .equals method

    What code are you using to get the keyboard input?

    The problem could be that the code you're using is, effectively though not literally, getNextWord(), rather then getNextEverythingIEnter().

Similar Threads

  1. check all purchase using methos equals without operator if
    By dimiby in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 13th, 2011, 08:17 AM
  2. Method Equals, Boolean...
    By boys8goods in forum Object Oriented Programming
    Replies: 1
    Last Post: June 25th, 2011, 03:34 PM
  3. 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
  4. [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
  5. Equals Method
    By Sninald in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 18th, 2010, 03:06 AM