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());

        if(stringTokenizer.nextToken() == "are"){



The output:

The total no. of tokens generated :  4

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

You should use the equals() method to compare Strings. The == operator mostly is for primitives.