What do square brackets mean? in java

What does this mean when they are square brackets before double . For example, double[] and is there any special way to use the return function when they are used in the method.

Example:

 public double[] MethodName(){ } 

What is the type of return value?

+7
java methods double brackets
source share
1 answer

Square brackets [] mean array. In your case of code:

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

You have a public MethodName method that returns an array. The double indicates the type of array, i.e. Stores an array of double objects.

EDIT: Forgot to answer the return question. But for your line of code, MethodName returns an array of type double (which will depend on the implantation inside the method body). Hope this helps (I'm also new to Java, climbing the ladder of SO rep)

+11
source share

All Articles