new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
12
Task/Search-a-list/Java/search-a-list-1.java
Normal file
12
Task/Search-a-list/Java/search-a-list-1.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
List<String> haystack = Arrays.asList("Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo");
|
||||
|
||||
for (String needle : new String[]{"Washington","Bush"}) {
|
||||
int index = haystack.indexOf(needle);
|
||||
if (index < 0)
|
||||
System.out.println(needle + " is not in haystack");
|
||||
else
|
||||
System.out.println(index + " " + needle);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue