Results 1 to 4 of 4
  1. #1
    louboulos is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default I wonder why this doesn't work...

    the contents in the arrays at position 0 are "1". I'm testing it with print. but for some reason this doesnt work. I want to test the first tokens to see if they are equal.


    Java Code:
    StringTokenizer st = new StringTokenizer(data[0]);
    String t1 = st.nextToken().toString();
    String t2 = st.nextToken().toString();
    String t3 = st.nextToken().toString();
    String t4 = st.nextToken().toString();
    StringTokenizer st2 = new StringTokenizer(users[0]);
    String tk1 = st2.nextToken().toString();
    String tk2 = st2.nextToken().toString();
    String tk3 = st2.nextToken().toString();
    String tk4 = st2.nextToken().toString();
    String tk5 = st2.nextToken().toString();
    
    System.out.println(t1);
    System.out.println(tk1);
    
        if(t1 == tk1){
        System.out.println("They Match!");
        }
    Last edited by louboulos; 05-13-2012 at 05:06 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: I wonder why this doesn't work...

    You will probably want to use String#split(...) rather than a StringTokenizer. Also, you'll never want to compare Strings using the == operator since this checks if one String *object* is the same as another String *object*, something you really don't care about. Instead use the equals(...) or equalsIgnoreCase(...) method of String.

  3. #3
    louboulos is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default Re: I wonder why this doesn't work...

    thank you very much!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Why. Does. This. Not. Work.
    By Kaytes in forum New To Java
    Replies: 1
    Last Post: 04-06-2012, 08:50 PM
  2. applet call dll work in Win2000 but not work in WinXP
    By manhcuongtin4 in forum Java Applets
    Replies: 1
    Last Post: 07-14-2011, 02:45 PM
  3. Getting SWT app to work on a different OS
    By Ravioli in forum SWT / JFace
    Replies: 0
    Last Post: 02-20-2011, 10:35 AM
  4. Cant seem to get this to work
    By nivekeleets in forum Java 2D
    Replies: 4
    Last Post: 11-13-2010, 08:09 PM
  5. how would i get this to work...?
    By deeadeed in forum New To Java
    Replies: 6
    Last Post: 12-06-2007, 03:58 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
  •