Why char[] is preferred over String for passwords in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why char[] is preferred over String for passwords in Java?

The password field in Swing has a getPassword() (syntax: public char[] getPassword() ) which returns char[] instead of getText() which returns String. Does String pose a security threat whwn it comes to passwords?

18th Apr 2018, 7:26 PM
esQmo_
esQmo_ - avatar
2 Answers
+ 1
A previous discussion on similar subject: https://www.sololearn.com/Discuss/1214318/?ref=app
18th Apr 2018, 8:01 PM
Ipang
+ 1
Thanks
18th Apr 2018, 8:02 PM
esQmo_
esQmo_ - avatar