String and Character Array in Java

前端 未结 6 1931
长情又很酷
长情又很酷 2020-12-31 16:12

I am a student who has just shifted from C++ to Java.

In Java what could be the main reason for defining separate data types for Strings and Char arrays? Wha

6条回答
  •  Happy的楠姐
    2020-12-31 16:44

    String is immutable in Java and stored in the String pool. Once it is created it stays in the pool until garbage collected.Since, String is immutable , the logging password is as readable string.It has greater risk of producing the memory dump to find the password.

    where as Char array is created in heap and you can override with some dummy values.

提交回复
热议问题