/** * Using an array as a parameter in a method.
* Call a method to input a date (3 integers: year, month and day * stored in array)
* Note: in terms of design, it would be better to define a Date class.
*/ import uwcse.io.*; public class ArrayAsAParameter { /** * Input and print a date. The input of the date is done * in an auxiliary private method. */ public void inputAndPrintADate() { // date variables int year, month, day; // The above variables have primitives types // We can't modify them from within a method // Use an array instead (of size 3) // int[] date = new ???? // Read the date with the readDate method // readDate(????) // Store the date in year, month and day // year = ??? // Print the date to check it } /** * Store in the array the input of the date.
* The modifications to the array are visible within * inputAndPrintADate. This is because an array is an object. */ private void readDate(/*????*/) { Input input = new Input(); // Get the year and store it in the array (element 0) // Get the month and store it in the array (element 1) // Get the day and store it in the array (element 2) } }