fork(2) 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.  
  13.  
  14. String text = "🥦_Salade verte";
  15.  
  16. /* We should avoid using endIndex = 1, as it will cause an invalid character in the returned substring. */
  17. // 1 : ?
  18. System.out.println("1 : " + text.substring(0, 1));
  19.  
  20. // 2 : 🥦
  21. System.out.println("2 : " + text.substring(0, 2));
  22.  
  23. // 3 : 🥦_
  24. System.out.println("3 : " + text.substring(0, 3));
  25.  
  26. // 4 : 🥦 S
  27. System.out.println("4 : " + text.substring(0, 4));
  28.  
  29. }
  30. }
Success #stdin #stdout 0.1s 50204KB
stdin
Standard input is empty
stdout
1 : ?
2 : 🥦
3 : 🥦_
4 : 🥦_S