2017 CSA FRQ 4A
This question involves reasoning about a two-dimensional (2D) array of integers. You will write two static methods, both of which are in a single enclosing class named Successors (not shown). These methods process a 2D integer array that contains consecutive values. Each of these integers may be in any position in the 2D integer array. For example, the following 2D integer array with 3 rows and 4 columns contains the integers 5 through 16, inclusive. | 0 1 2 3 ------------------ 0 | 15 5 9 10 1 | 12 16 11 6 2 | 14 8 13 7 The following Position class is used to represent positions in the integer array. The notation (r, c) will be used to refer to a Position object with row r and column c. public class Position { /** Constructs a Position object with row r and column c. */ public Position(int r, int c) { / * implementation not shown * / } } Write a static method findPosition that takes an integer value and a 2D integer array and returns the position of the integer in the given 2D integer array. If the integer is not an element of the 2D integer array, the method returns null. For example, assume that array arr is the 2D integer array shown at the beginning of the question. - The call findPosition(8, arr) would return the Position object (2,1) because the value 8 appears in art at row 2 and column 1. - The call findPosition(17, arr) would return null because the value 17 does not appear in arr. public static Position findPosition(int num, int[][] intArr) { USER CODE GOES HERE }