Is it good practice to invalidate String in java

I have a problem storing a simple password in memory as a String. According to the link, since Strings are immutable , there is a vulnerability to using the String data type to store sensitive data in memory.

https://www.geeksforgeeks.org/use-char-array-string-storing-passwords-java/

Why is char [] preferred over String for passwords?

Can I overcome this security issue by changing a string variable instead of using a char array or String buffer / builder.

for example: String password = "password"; password = null;

+4
source share
2 answers

. delink. - . .

, .

, char [], . char .

.

String Constant pool.

+4

, . .

, , . ( "" ), , ( ) .

, char, .

+2

Source: https://habr.com/ru/post/1694799/


All Articles