0

I have this code where stringArray contains 1000 words and String[] a contains words which are split into two columns a[0] and a[1].

So, now a[0] contains all words and a[1] contains keys and I want to compare a[0] with another array. How should I do this?

String[] stringArray = swn.mylist.toArray(new String[0]);
String[] a = new String[stringArray.length+1];

for(String words: stringArray) {  
    a = words.split("#");
    System.out.println(a[0]);
}
1

2 Answers 2

1

I guess you are looking for this kind of code:

String[] stringArray = {"Hel#lo","Wel#come","Te#st","I#n","Ja#va"};
String[] a;

for (String words : stringArray) {
    a = words.split("#");
    System.out.println(a[0]);
}
Sign up to request clarification or add additional context in comments.

Comments

0

Use equals instead of ==.

For example :

if(word.equals("")){
    //result
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.