Results 1 to 3 of 3
  1. #1
    juhiswt is offline Member
    Join Date
    Mar 2011
    Posts
    30
    Rep Power
    0

    Default Why this block is not working properly?

    do
    {
    try
    {
    q.enque();
    }

    catch(MyException e)
    {

    System.out.println(e);
    }
    System.out.println("Do u want to add more elements?IF Yes then press y");
    choice=S.nextLine();
    }while(choice=="Y"&&choice =="Y");

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by juhiswt View Post
    }while(choice=="Y"&&choice =="Y");
    Don't compare two Strings for equality with the == operator; Java is not Basic. Use the equals( ... ) method instead and read the API documentation for the String class (and read some elementary tutorials to find out how comparing two objects work).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. date is not working properly
    By newnewgen in forum New To Java
    Replies: 1
    Last Post: 10-12-2010, 09:04 AM
  2. Replies: 4
    Last Post: 01-10-2009, 12:17 AM
  3. event handler not working properly
    By H3rtaherta in forum Java 2D
    Replies: 3
    Last Post: 11-24-2008, 02:39 AM
  4. My code is not working properly ..modify it
    By Shyam Singh in forum New To Java
    Replies: 14
    Last Post: 07-16-2008, 05:48 PM
  5. Log4j not working properly....
    By prakash_dev in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 12:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •