About 376,000 results
Open links in new tab
  1. java - How to use a method to return a double array of user input ...

    I want to create a method that returns a double array of user input values. I've figured out how to create a method to ask the user to pick how many elements an array should hold, then pass off the size to next method, which is to spit out a double array of user's input values.

  2. How to Return an Array in Java? - GeeksforGeeks

    Jun 29, 2022 · The java.lang.reflect.Array.getShort() is an in-built method of Array class in Java and is used to return the element present at a given index from the specified Array as a short. Syntax: Array.getShort(Object []array,int index) Parameters: array: The object array whose index is to be returned. inde

  3. java - How to obtain return type double? - Stack Overflow

    Feb 14, 2013 · if(myArrayList.size() >= 2) { Double t = myArrayList.get(myArrayList.size()-1); Double d = myArrayList.get(myArrayList.size()-2); result = ( t+ d ) / 2 ; System.out.println("Average is: "+result); } return result; }

  4. arrays - return type []double issue in java - Stack Overflow

    Jul 28, 2012 · return (new double[]{latitude,longitude}); So, what is difference between them? While java supports declarations data_type [] var_name as well as data_type var_name []. Maybe you should write double[] instead of []double... [] data_type is not valid in Java.

  5. How to Return Multiple Values From a Java Method - Baeldung

    May 11, 2024 · In this tutorial, we’ll learn different ways to return multiple values from a Java method. First, we’ll return arrays and collections. Then we’ll demonstrate how to use container classes for complex data, and learn how to create generic tuple classes. Finally, we’ll illustrate how to use third-party libraries to return multiple values. 2.

  6. Double Array in Java - Know Program

    An array in Java used to store multiple double values in a single variable called a double array. Example = {10.0, 15.9, 20.8, 45.5, 50.9}

  7. Java Arrays - How to return array in java from method?

    Nov 22, 2021 · Java Return Array - double [] primitive & wrapper array. Below example returns a double [] array from the method. Example 2: numbers[i] = i + 1; } return numbers; } // returning Double wrapper array from method public static Double[] getDoubleWrapper(int size) { Double[] numbers = new Double[size]; for (int i = 0; i < size; i++) { .

  8. Array getDouble () Method in Java - GeeksforGeeks

    Nov 30, 2018 · The java.lang.reflect.Array.getDouble() is an inbuilt method of Array class in Java and is used to return the element present at the given index from the specified Array as Double. Syntax : Array.getDouble(Object []array, int index)

  9. How to Return Array in Java - Scientech Easy

    Feb 14, 2025 · Learn how to return an array in java with example, syntax for returning one dimensional array from a method, 2D array from a method in java

  10. How to Return Array in Java - Delft Stack

    Feb 2, 2024 · To do this, we use Arrays.toString() that takes an array as the only argument and converts the array to a string. String intArrayAsString = Arrays.toString(returnArrayInt()); . String doubleArrayAsString = Arrays.toString(returnArrayDouble()); . String arrayAsString = Arrays.toString(returnArrayString()); .

  11. Some results have been removed
Refresh