You can use braces notation only at the point of declaration, where compiler can infer the type of array from the declaration type.
To use it anywhere else you need to use Array Creation Expression:
return new double[] {0,1,2};
More Related Contents:
- How does array work? How to create a basic array data structure using java? [closed]
- Multiplication based on input integer and return array- Need help in storing array while looping
- How to check two array list are same content in same position
- How to refacor a code use only loops and simple arrays?
- error: incompatible types: ‘Something’ cannot convert to ‘Something’
- Arrays.asList() not working as it should?
- Java arrays printing out weird numbers and text [duplicate]
- A quick and easy way to join array elements with a separator (the opposite of split) in Java [duplicate]
- How to convert Java String into byte[]?
- Sort a two dimensional array based on one column
- Comparing two integer arrays in Java
- Immutable array in Java
- Any way to declare an array in-line?
- Quickest way to find missing number in an array of numbers
- Lambda expression to convert array/List of String to array/List of Integers
- Converting String to “Character” array in Java
- Grab a segment of an array in Java without creating a new array on heap
- pass array to method Java
- Byte Array to Image object
- Java array with more than 4gb elements
- Print ArrayList
- How to convert a Byte Array to an Int Array
- Issue with parsing the content from JSON file with Jackson & message- JsonMappingException -Cannot deserialize as out of START_ARRAY token
- Java read file and store text in an array
- When to use a List over an Array in Java?
- Looping through the elements in an array backwards [duplicate]
- Sorting int array in descending order [duplicate]
- Java: Array with loop
- How to convert HashMap to json Array in android?
- Compare two arrays of primitives in Java?