Results 1 to 3 of 3
  1. #1
    Join Date
    May 2008
    Posts
    7
    Rep Power
    0

    Default question on string tokenizer

    when i split a string into tokens and comparing with another string its giving me false can any body help me out

    String str="hello this is pardhu:at hyderabad;";
    if i split it and compars as
    StringTokenizer st=new StringTokenizer(str,":;");
    while(st.hasMoreTokens())
    {
    if(st.hasMoreTokens.equalsIgnoreCase("hellothis is pardhu"))
    {
    ......
    ......
    }

    }
    it is returining false can some body help me out

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You don't have deal with the next token here. Simply you don't start to find the first token either.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Keep in mind that, equalsIgnoreCase() not support for the patterns. I mean strings you comparing are not in same length. Because you have remove a white space in the second string.

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM
  2. Replies: 2
    Last Post: 09-18-2008, 08:30 AM
  3. Replies: 0
    Last Post: 11-20-2007, 05:59 PM
  4. Replies: 1
    Last Post: 08-07-2007, 08:29 AM
  5. Replies: 1
    Last Post: 08-03-2007, 11:52 AM

Posting Permissions

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