Hi all, I have a slight problem when checking if a "Token" is in my StringTokenizer string.
My code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.String.*;
import java.util.*;
public class TextAnalyser {
public static void main( String args )
{
StringTokenizer stringTokenizer = new StringTokenizer("You are tokenizing string");
System.out.println("The total no. of tokens generated : " + stringTokenizer.countTokens());
while(stringTokenizer.hasMoreTokens()){
System.out.println(stringTokenizer.nextToken());
if(stringTokenizer.nextToken() == "are"){
System.out.println("Lol");
}
}
}
}
The output:
The total no. of tokens generated : 4
You
tokenizing
So i'm trying to recognise a certain string token to pick up and print it out. Eventually I want to take it out, however it does not display "Lol" and it also doesn't display string?
Not sure if i'm going to right way about using nextToken(), but i don't see what else i could use