fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) {
  11. args = new String[] {"house", "bike","dog"};
  12. List<String> words = new ArrayList<>();
  13. words.addAll(Arrays.asList("house", "bike","dog","house","house"));
  14. System.out.println(getIntegerArray(words,args));
  15. }
  16.  
  17. public static List<Integer> getIntegerArray(List<String> words, String[] findwords) {
  18. List<Integer> numbers = new ArrayList<>();
  19. for(String word: findwords)
  20. numbers.add(words.indexOf(word));
  21. return numbers;
  22. }
  23. }
Success #stdin #stdout 0.08s 47012KB
stdin
Standard input is empty
stdout
[0, 1, 2]