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

Thread: Having problem to stop reading strings

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

    Lightbulb Having problem to stop reading strings

    System.out.println ("Enter Books Names, Enter ST to Stop Reading:");

    for (i = 0; i < 10; i++)

    {

    Names [i] = S.next ();

    if (Names [i] == "ST")

    break;

    }

    When I type St, nothing happened and the loop continues ?! This not happened to me before when i use integers.

    Thank u in advance


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

    Default Re: Having problem to stop reading strings

    could you pls post more of your code? It's hard for me to understand your code.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Having problem to stop reading strings

    In addition to the above comment, please see the following common java mistake:
    http://www.javaprogrammingforums.com...html#post18725

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

    Default Re: Having problem to stop reading strings

    oh, sorry guys. The program ask to enter names, say the loop length is 10 but i want to exit after 3 entries. how to exit the loop?

Similar Threads

  1. Replies: 36
    Last Post: July 25th, 2011, 10:27 AM
  2. [SOLVED] Problem in File Reading...
    By Mr.777 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 20th, 2011, 07:24 AM
  3. Stop a while loop with an awt button, problem
    By frx08 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 20th, 2011, 08:24 AM
  4. reading content of the text file, splitting it into strings
    By Dodo in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: January 6th, 2011, 07:57 PM
  5. Problem on reading file in Java program
    By nathanernest in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: April 13th, 2009, 08:14 AM