Why do C# and Java bother with the “new” operator?

后端 未结 9 1126
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 13:59

Why does the new operator exist in modern languages such as C# and Java? Is it purely a self documenting code feature, or does it serve any actual purpose?

For insta

9条回答
  •  执笔经年
    2020-12-03 14:44

    The new operator allocates the memory for the object(s), which is it's purpose; as you say it also self documents which instance(s) (i.e. a new one) you're working with

提交回复
热议问题