java - finding if the strings in an array is exists in another array -


i have array string[] questions={"adorable", "able", "adventurous"}; , have array t[] contains adjectives. find words adorable, able , adventurous in array t[]. far have line codes doesn't seem work. can please me?

    string u = sn.nextline();     string[] t = u.split(" ");     (y = 0; y <= question.length; y++) {         (int w = 0; w < t.length; w++) {             if (t[w].equals(question[y])) {                 system.out.print(t[w] + " ");                 break;             }         }     } 

do :

for (int y = 0; y < question.length; y++) {  } 

instead of <=. problem outcomes fact don't have question[question.length] element.

also, don't see declare y variable.

update: here's complete sample:

string[] questions = {"adorable", "able", "adventurous"}; string u = "able adorable asd"; string[] t = u.split(" "); (int y = 0; y < questions.length; y++) {    (int w = 0; w < t.length; w++) {        if (t[w].equals(questions[y])) {            system.out.print(t[w] + " ");            break;        }     } } 

this prints:

adorable able 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -