0

The seems like it would be easy and basic but I just don't know enough about Java/Android and don't know how to get a specific value from an array. Do you have to iterate though it or can you just call the key/value pair or smth? Any example would be grateful.

thanks e.g.

String[] x = Pattern.compile(";").split(CookieManager.getInstance().getCookie(URL));

Now if there is a key of ID how do I get that value which should be the 2nd key? X[1]? Just doesn't work.

3
  • What do you mean x[1] doesn't work? Is it giving you an error? Commented Apr 9, 2013 at 18:23
  • 1
    x[1] should indeed get you the 2nd item in the array. Perhaps the array doesn't contain 2 elements, then you'd get an exception. Might want to check how long it is with 'x.length;' prior to fetching an item. Commented Apr 9, 2013 at 18:26
  • It did work. I accidentally had quotes around the number but put it correct in my question. doh. Commented Apr 9, 2013 at 18:30

1 Answer 1

1
String a = x[0];
String b = x[1];

or

for (String z : x)
{
   String valor = z;
}

I wait help you!

Sign up to request clarification or add additional context in comments.

1 Comment

If my answer realy help you, please, mark my answer with solution of your problem.

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.