Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what do the square brackets mean? in Java

What does it mean when there are square brackets in front of double. For example double[]? Is there any special way to use the return function when using them in a method.

For example:

public double[] MethodName(){

}

What is the type of the return value?

like image 843
Supernaturalgirl 1967 Avatar asked Oct 23 '14 21:10

Supernaturalgirl 1967


1 Answers

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)

like image 191
12341234 Avatar answered Oct 31 '22 05:10

12341234