User616263
User616263

Reputation: 467

compare arraylist with string

I want to compare two variables the first arraylist and the second is string

How can i convert the String to arrayList to compare those values in the variables

thank you in advance

Upvotes: 0

Views: 626

Answers (1)

Ollie C
Ollie C

Reputation: 28509

Hard to understand your question, but if your String is like this "cat,dog,elephant" then you can use String.split(",") to get a String array, and then convert that to an ArrayList like this:

ArrayList<String> arrayList = new ArrayList(Arrays.asList(myString.split(",")));

Upvotes: 2

Related Questions