-3

I am struggling to properly output the elements of an array in java. I know I should use a for loop to print out the array, but I am not sure exactly where to start in order to make sure all the values are printed after the function call in main. Any advice would be appreciated. Thank you!

/*
1 creator shares with 3 friends
1 minute = 3 shares/ friend
what does it look like after 10 mins
*/
public int[] shares(int minutes, int people){
    int[] array = new int [20];
    for(int i = 1; i <= minutes; i++){
        people += Math.pow(3, people);
        array[i] = people;
    }
    return array;
}

public static void main(String args[]){
    Prc test = new Prc();
    System.out.println(test.shares(10, 1));
}
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
amr
  • 5
  • 5

1 Answers1

0

In arrays, you should start with zero. The for loop could be something like this:

for(int i=0; i<myArray.length; i++){
System.out.println(myArray[i]);
}