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 str = "Hello";
  13. String a = str.substring(2, 4); // a is "ll" (not "llo")
  14. String b = str.substring(0, 3); // b is "Hel"
  15. String c = str.substring(4, 5); // c is "o" -- the last char
  16. String e = str.substring(0, str.length() - 1); // c is "o" -- the last char
  17. System.out.println(e);
  18. }
  19. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Hell