Question: The language is Java, Need help changing my One-dimensional array to a two-dimensional array import java.util.Arrays; import java.util.Random; public class ArrayReview { private int[] array;

The language is Java, Need help changing my One-dimensional array to a two-dimensional array

import java.util.Arrays; import java.util.Random;

public class ArrayReview { private int[] array; public ArrayReview(int length) { Random r = new Random(100); array = new int[length]; for(int i =0 ;i

public void setArray(int[] array) { this.array = array; } public void setKthItem(int k, int item) { array[k] = item; } public int pickMaxIndex( int start, int end) { int max = array[start]; int index=start; for(int i = start + 1 ;i< end ;i++) { if(array[i] >= max) { max = array[i]; index=i; } } return index; } public void swap(int i , int j) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } public void selectSort() { int max;int pos; for(int i = 0;imax) { max = array[j]; pos = j; } } swap(i,pos); } } public void printArray() { for(int value:array) System.out.println(value+ " "); } public static void main(String[] args) { ArrayReview a1=new ArrayReview(5); System.out.println(a1); System.out.println(" Index of maximum number from 0 to 4 is: "+a1.pickMaxIndex(0, 4)); a1.swap(2, 3); System.out.println(" After swaping array is : "); System.out.println(a1); a1.selectSort(); System.out.println(" After sorting array is : "); System.out.println(a1); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!