I have the following code
I'm trying to compare two arrays. The first array is the user input, for example can we use the followiingCode:import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
public class SQL {
public static void main(String[] args)throws IOException{
String text = JOptionPane.showInputDialog("Please enter your sentence here");
String text2= null;
String Text3 = "";
StringTokenizer st;
String[] keyword = {"employees", "managers"};
st = new StringTokenizer (text, " ");
while (st.hasMoreElements()){
text2 = (st.nextToken());
System.out.println (text2);
Text3 = Text3 + " " + text2;
}
String[] words = Text3.split (" ");
//System.out.println(words);
for (int i=0; i < words.length; i++){
System.out.println (words[i]);
}
}
}
'show all employees who are managers'
I have the second array which is called keyword. I want the keyword array to search through the user input (which is stored as an array now) and identify if both keywords are mentioned by the user?
I think its an if statement but I'm not sure how to go about it.
I had the following structure in mind
if userinput array was equal to keyword1 AND userinput array was equal to keyword 2
then do this.
its just the array searching which I'm struggling with.
Does anyone have any ideas that might be able to help as I can only find examples of array comparison to see if two arrays are identical.
/Mitty

