So this class take the value of endMiles and startMiles from the main class. Then it would calculate the distance by subtracing the startMiles from endMiles then returning the value of distanceV(This is the variable I use). As you can see I have a method to return the value of distanceV, this work perfectly fine but I'm calculating more than one distance so I want to put all the distanceV into an array. I have two method to put the distanceV to an array but when I return it and try to print it in the main method, it give me some random characters. Thanks
public class AnnualFuelUse { //Variables private int endVMiles , startVMiles, distanceV; private int [] distanceArray = new int[4]; //Constructor AnnualFuelUse(int endMiles,int startMiles) { endVMiles = endMiles; startVMiles= startMiles; distanceV = 0; } //Calculation public void calcDistance() { distanceV = endVMiles - startVMiles; } //Return startDistance public int getStart() { return startVMiles; } //Return endDistance public int getEnd() { return endVMiles; } //Return distance public int getDistance() { return distanceV; } //Calc distanceArray public void calcArray() { for(int index = 0 ; index < distanceArray.length; index++) { distanceArray[index] = distanceV; } } //Return distanceArray public int[] getArray() { return distanceArray; } }