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) throws java.lang.Exception
  11. {
  12. String sam = "hey there";
  13. String ben = "hey thar";
  14.  
  15. System.out.println(sam + " " + ben);
  16. System.out.println( sam.indexOf('h') );
  17. System.out.println( sam.indexOf('7') );
  18. System.out.println( ben.indexOf('a') );
  19. System.out.println( ben.indexOf( 'y') );
  20. System.out.println( sam.indexOf("ey") );
  21. System.out.println( ben.indexOf("ar") );
  22. System.out.println( sam.charAt(3) );
  23. System.out.println( sam.charAt(0) );
  24. System.out.println( sam.substring(3,6) );
  25. System.out.println( sam.substring(0,4) );
  26. System.out.println( sam.equals(ben) );
  27. System.out.println( sam.compareTo(ben) );
  28. System.out.println( ben.compareTo(sam) );
  29. System.out.println( ben.compareTo("abc") );
  30. System.out.println( ben.replaceAll("e","#") );
  31. System.out.println( ben.replaceAll("#","*") );
  32. System.out.println( ben.length() );
  33. System.out.println( sam.length() );
  34.  
  35.  
  36.  
  37. }
  38. }
Success #stdin #stdout 0.1s 36340KB
stdin
Standard input is empty
stdout
hey there hey thar
0
-1
6
2
1
6
 
h
 th
hey 
false
4
-4
7
h#y thar
hey thar
8
9