Java: Why can't return array using {..} without new operator?

前端 未结 5 656
忘掉有多难
忘掉有多难 2021-01-04 05:58

I have searched a lot on the website, but didn\'t find any related question. So I believe it is not a duplicate.

I know we can initialize an array with 3 ways:

5条回答
  •  鱼传尺愫
    2021-01-04 06:40

    1st Question answer:- {a,b,c} are the values to giving to array at the time of compilization. So, the name of the stuff is array initialization.... and those are not literals

    2nd question answer:- The difference is []{a,b,c} calling the parameterised constructor and {a,b,c} just intilizing the array...

    3rd: I cant get your questing

    4th: yes both are constructors....

提交回复
热议问题