Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WordSearch {
- static String[] findWord(String x, String[] y) {
- ArrayList<String> returnedList = new ArrayList<String>();
- for (int i = 0; i < y.length; i++) {
- if (y[i].toLowerCase().contains(x.toLowerCase()))
- returnedList.add(y[i]);
- }
- if (returnedList == null)
- returnedList.add("Empty");
- String[] simpleArray = new String[returnedList.size()];
- returnedList.toArray(simpleArray);
- return simpleArray;
- }
- public static void main(String[] args) {
- String x = "chuj";
- String[] y = { "chuj", "fdsfd", "fdsfs", "chuj" };
- String[] arrray = WordSearch.findWord(x, y);
- for (String row : arrray) {
- System.out.println(row);
- }
- System.out.println("Razem: " + arrray.length);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement