First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
11
Task/Search_a_list/Java/search_a_list-2.java
Normal file
11
Task/Search_a_list/Java/search_a_list-2.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
String[] haystack = {"Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"};
|
||||
|
||||
OUTERLOOP:
|
||||
for (String needle : new String[]{"Washington","Bush"}) {
|
||||
for (int i = 0; i < haystack.length; i++)
|
||||
if (needle.equals(haystack[i])) {
|
||||
System.out.println(i + " " + needle);
|
||||
continue OUTERLOOP;
|
||||
}
|
||||
System.out.println(needle + " is not in haystack");
|
||||
}
|
||||
12
Task/Search_a_list/Java/search_a_list.java
Normal file
12
Task/Search_a_list/Java/search_a_list.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