fork(1) download
  1. import java.util.*;
  2.  
  3. class Example {
  4. public static void main(String[] args) {
  5. String s = new String(new char[10]).replace("", "hello");
  6. s = s.replace("\0", "X");
  7. System.out.println(s);
  8.  
  9. int helloCount = s.split("X").length;
  10. System.out.println(helloCount + " hellos for 10 characters");
  11. }
  12. }
Success #stdin #stdout 0.09s 28088KB
stdin
Standard input is empty
stdout
helloXhelloXhelloXhelloXhelloXhelloXhelloXhelloXhelloXhelloXhello
11 hellos for 10 characters