The task is: Write an method printArray. It shall take an int array as parameter. It shall write every int in the array on a row (system out print) If the parameter is null, nothing shall be written.
In my code I get this message: The method println(boolean) in the type PrintStream is not applicable for the arguments (void).
MY CLASS:
public class Upg9_tenta {
public static void printArray(int arr[]){
int i = 0;
while(i<arr.length){
System.out.print(arr[i]);
i++;
}
}
}
MY MAIN:
public class Upg9_tentamain {
public static void main (String []args){
int []arr = {1, 3, 8, 6};
Upg9_tenta.printArray(arr);
System.out.println(Upg9_tenta.printArray(arr));
}
}