Is the `new` keyword in java redundant?

后端 未结 5 1460
闹比i
闹比i 2020-11-29 05:29

I am coming from C++ so there is one feature of java that I don\'t quite understand. I have read that all objects must be created using the keyword new, with th

5条回答
  •  既然无缘
    2020-11-29 05:51

    Believe it or not, requiring the use of new for constructors is a namespacing thing. The following compiles just fine:

    public class Foo {
        public Foo() {}
        public void Foo() {}
    }
    

提交回复
热议问题