java - Getting the size on an array from one method into another method where I will be filling the array with numbers -


i must ask user size of array. method must integer. must pass value method user fill array, method must float.

it's throwing error in line float[] arraysize = new float [getlengthofarray()]; in second method.

the error says "int[] cannot converted int". don't know do.

here's entire code

    package exercise;  import javax.swing.joptionpane;  public class exercise3 {      public static int[] arraylenght(){         int arraysize = integer.parseint(joptionpane.showinputdialog("enter array size"));         int[] totalarraysize = new int[arraysize];         return totalarraysize;     }      public static float[] fillarray(){         float[] arraysize = new float [arraylenght()];          (int = 0; < arraysize.length; i++) {             arraysize[i] = float.parsefloat(joptionpane.showinputdialog("enter number"));         }         return arraysize;     }      public static void calculatearithmeticaverage(float[] numbers){         int total = 0;         int average = 0;          (int = 0; < numbers.length; i++) {             total += numbers[i];         }         average = total / numbers.length;      }      public static void main(string[] args) {         calculatearithmeticaverage(fillarray());     } 

your arraylength method should return int, not array.

public static int arraylength() {     int arraysize = integer.parseint(joptionpane.showinputdialog("enter array size"));     return arraysize ; } 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -