-2
 public static int fiveOfaKind(int dice[]){

Obviously it is declaring a method but what I'm confused about is the part that goes "(int dice[])"

dice is an integer array that was declared in the main method.

What does that bit in the parenthesis do? And what is it called, I want to look it up and read about it.

Voxle
  • 29
  • 3

2 Answers2

0

What does that bit in the parenthesis do?

It requires that it is an array of variable length.

what is it called

Square brackets

Hope that helps...

hd1
  • 33,938
  • 5
  • 80
  • 91
0

It's a parameter for the method. The dice array declared in the main method is in a different scope and unrelated to this method.

public static void printArr(int arr[]) {
    for(int i = 0; i < arr.length; i++){
        System.out.println(arr[i]);
    }
}

public static void main(String args[]) {
    int[] dice = new int[5];
    ...


    foo(dice);
}

In this example you have a method that takes an array and prints the elements in it. In the main method you pass this array to the method as a parameter.

https://www.w3schools.com/java/java_methods_param.asp

Major Ben
  • 139
  • 1
  • 10