Java string replace and the NUL (NULL, ASCII 0) character?
Does replacing a character in a String with a null character even work in Java? I know that ‘\0’ will terminate a c-string. That depends on how you define what is working. Does it replace all occurrences of the target character with ‘\0’? Absolutely! String s = “food”.replace(‘o’, ‘\0’); System.out.println(s.indexOf(‘\0’)); // “1” System.out.println(s.indexOf(‘d’)); // “3” … Read more