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 Main
  9. {
  10. public static boolean punyaHuruf(String kataPertama, String kataKedua){
  11. kataPertama = kataPertama.toLowerCase();
  12. kataKedua = kataKedua.toLowerCase();
  13.  
  14. for(char c : kataPertama.toCharArray()){
  15. if (kataKedua.indexOf(c) == -1){
  16. return false;
  17. }
  18. }
  19. return true;
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. System.out.println(punyaHuruf("cat", "antarctica"));
  25. System.out.println(punyaHuruf("cat", "australia"));
  26. System.out.println(punyaHuruf("cat", "ANTARTICA"));
  27. }
  28. }
Success #stdin #stdout 0.08s 54344KB
stdin
Standard input is empty
stdout
true
false
true