what do the square brackets mean? in Java

前端 未结 1 530
陌清茗
陌清茗 2021-01-04 22:56

What does it mean when their are square brackets in front of double. For example double[] and is there any special way to use the return function

相关标签:
1条回答
  • 2021-01-04 23:46

    Square brackets [] would indicate an array. In your case of code:

    public double[] MethodName(){ .... }

    You have a public method MethodName which returns an array. Double indicates what type the array is, i.e. stores an array of objects of type double.

    EDIT: Forgot about answering your return question. But for your line of code, MethodName would return an array of type double (which would depend on the implmentation inside the method body). Hope that helps (I'm new to Java too; climbing the SO rep ladder)

    0 讨论(0)
提交回复
热议问题