How can you pass a two-dimensional array to a method? Provide some examples.

What will be an ideal response?


When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array. A method that receives a two-dimensional array uses two bracket pairs following the data type in the parameter list of the method header. For example, the following method headers accept two-dimensional arrays of ints, doubles, and Employees, respectively:?public static void displayScores(int[][]scoresArray)public static boolean areAllPricesHigh(double[][] prices)public static double computePayrollForAllEmployees(Employee[][] staff)?In each case, notice that the brackets indicating the array in the method header are empty. There is no need to insert numbers into the brackets because each passed array name is a starting memory address. The way you manipulate subscripts within the method determines how rows and columns are accessed.

Computer Science & Information Technology

You might also like to view...

When a pointer variable has the indirection operator in front of it (like *x_ptr), what does this order tell the program?

What will be an ideal response?

Computer Science & Information Technology

Case-Based Critical Thinking QuestionsCase 9-1Tara has just gotten her first computer connected to the Internet. She is very excited to start e-mailing her friends and family. Tara wants to send her aunt some pictures from her last vacation. While attempting to attach the pictures individually to an e-mail, she notices that the file sizes are just too big. In order to easily remedy this problem, Tara should ____.

A. attach each picture to its own separate e-mail B. compress all of the pictures into one smaller file with a .zip extension C. send her aunt the pictures through the Post Office; e-mail is not made for sending pictures D. learn how to make a Web site and post her pictures there

Computer Science & Information Technology

At what layer of the OSI Reference Model does packet filtering occur?

a. Data link b. Network c. Transport d. Application

Computer Science & Information Technology

What cloud application offers a variety of cloud services, including automation and CRM, cloud application development, and Web site marketing?

a. IBM Cloud b. Amazon EC2 c. Salesforce d. HP Helion

Computer Science & Information Technology