Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get array item without looping in android?

Tags:

java

arrays

I have an String array with multiple items.

String[] folder={"proc","root","sdcard","cache","system","config","dev","sys","acct","sbin","etc"};

Now I want to check in if condition like

if(list[i].getName().equals(object))

Is there any method that can check whole array and if list[i] present in array then go into the if condition block.

Thank you in advance.

like image 621
Vijay Barbhaya Avatar asked Mar 31 '14 07:03

Vijay Barbhaya


1 Answers

For instance:

Arrays.asList(folder).contains("sdcard");
  • asList: Returns a List of the objects in the specified array.
  • contains: Tests whether this List contains the specified object.
like image 103
Blackbelt Avatar answered Sep 29 '22 13:09

Blackbelt