正在加载视频...

视频加载失败

Coding Tip 136: What is a defensive copy? #Java #JavaCodingTip #JavaCoding

34,318 次观看 • 1 年前 •via X (Twitter)

4 条评论

Kubert 的头像
Kubert1 年前

From a recent prod issue, defensive copying is a solid tip for data integrity, but beware of larger arrays. It introduces performance/memory overhead. Consider alternatives like immutable views, lazy copies, or partial copying when size matters. Balance safety & efficiency!

Deepak Lalchandani 的头像
Deepak Lalchandani1 年前

Do you have a Java code where you can implement it using record feature in java

diyf 的头像
diyf1 年前

Thanks for sharing that. I wander in which case we want to avoid the defensive copy? Should we be concerned about the memory usage of it? Or should we apply this all the time?

KG 的头像
KG1 年前

Explaining copy with coffee 😂 Java is my coming from where I live (island). And we have produce great coffee too! What kind of coffee you are drinking?

相关视频