Advertisement
Guest User

pomoc dla mirka

a guest
Aug 21st, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. class WordSearch {
  2.     static String[] findWord(String x, String[] y) {
  3.  
  4.         ArrayList<String> returnedList = new ArrayList<String>();
  5.  
  6.         for (int i = 0; i < y.length; i++) {
  7.             if (y[i].toLowerCase().contains(x.toLowerCase()))
  8.                 returnedList.add(y[i]);
  9.  
  10.         }
  11.  
  12.         if (returnedList == null)
  13.             returnedList.add("Empty");
  14.  
  15.         String[] simpleArray = new String[returnedList.size()];
  16.         returnedList.toArray(simpleArray);
  17.  
  18.         return simpleArray;
  19.     }
  20.  
  21.     public static void main(String[] args) {
  22.  
  23.         String x = "chuj";
  24.         String[] y = { "chuj", "fdsfd", "fdsfs", "chuj" };
  25.         String[] arrray = WordSearch.findWord(x, y);
  26.  
  27.         for (String row : arrray) {
  28.             System.out.println(row);
  29.            
  30.         }
  31.         System.out.println("Razem: " + arrray.length);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement