fork download
  1.  
  2. class Ideone
  3. {
  4. public static void main (String[] args) throws java.lang.Exception
  5. {
  6. String s = "Ishikaika";
  7.  
  8. // searching
  9. System.out.println(s.contains("sh"));
  10. System.out.println(s.indexOf('k'));
  11. System.out.println(s.indexOf("ika"));
  12. System.out.println(s.lastIndexOf("ika"));
  13. System.out.println(s.startsWith("Ish"));
  14. System.out.println(s.endsWith("ika"));
  15.  
  16. // extraction/ transformations
  17. System.out.println(s.substring(3)); // from given index till end of string
  18. System.out.println(s.substring(3, 6)); // start and end index [start, end)
  19.  
  20. System.out.println(s.toUpperCase());
  21. System.out.println(s.toLowerCase());
  22.  
  23. String s1 = " drum sticks ";
  24. System.out.println(s1.trim());
  25. System.out.println(s1.strip()); // unicode friendly
  26.  
  27. String s2 = "helperhelps";
  28. System.out.println(s2.repeat(3));
  29. System.out.println(s2.replace('l', 'u'));
  30. System.out.println(s2.replace("lp", "uk"));
  31. System.out.println(s2.replaceAll("lp", "uk"));
  32. String s3 = "hello-hi-bye-world";
  33. String[] arr = s3.split("-");
  34. for(String i: arr)
  35. System.out.println(i);
  36.  
  37. System.out.println(String.join(",", "a","b","c"));
  38. }
  39. }
Success #stdin #stdout 0.07s 55088KB
stdin
Standard input is empty
stdout
true
4
3
6
true
true
ikaika
ika
ISHIKAIKA
ishikaika
drum sticks
drum sticks
helperhelpshelperhelpshelperhelps
heuperheups
heukerheuks
heukerheuks
hello
hi
bye
world
a,b,c