Câu hỏi phỏng vấn Strings
Câu hỏi

Why is char[] preferred o...

Câu trả lời

Here are a few reasons why char[] is preferred over String for storing passwords:

Security

  • Strings are immutable in Java, meaning once a String object is created, its value cannot be changed. This means the password remains in memory even after it's no longer needed.
  • Strings are also often cached by the JVM and can end up in various logs, dumps, etc. exposing the password.
  • char[] on the other hand can be overwritten with zeros after use, securely removing the password from memory.

Performance

  • Strings are more heavyweight objects compared to char arrays. Creating and destroying Strings has more overhead.
  • Strings ...
senior

senior

Gợi ý câu hỏi phỏng vấn

junior

What is strings mutability and immutability?

expert

When is Rabin-Karp more effective than KMP or Boyer-Moore?

expert

What are the main differences between the Knuth-Morris-Pratt search algorithm and the Boyer-Moore
search algorithm?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào