I made the mistake of storing a password as a String in a Java program. I would like to prevent this String password from appearing in a heap dump/memory dump. Ideally, I should have used a char[] and filled it with zero after use (as recommended by this article - https://nvisium.com/resources/blog/2016/03/31/secure-password-strings.html).
I read some SO posts and understood that strings are immutable and they cannot be overwritten. My question is - Is there no way to replace the contents of a string already created with zeroes?
Note: I cannot change my implementation to use a char[] now as I get this String from a module/library which returns a String.