0

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

1
  • 1
    You need to provide a lot more info here. What kind of comparison do you want? Commented Apr 1, 2011 at 18:27

1 Answer 1

2

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(",")));
Sign up to request clarification or add additional context in comments.

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.