Reputation: 467
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
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