Question: public class Exercise1 { public static void printArray(int[][] myArray) { for (int i = 0 ; i < myArray.length ; i++) { for (int j
public class Exercise1 { public static void printArray(int[][] myArray) { for (int i = 0 ; i < myArray.length ; i++) { for (int j = 0 ; j < myArray[i].length ; j++) { System.out.print(myArray[i][j] + " "); } /* Print for propper spacing */ System.out.println(); } /* Print for propper spacing */ System.out.println(" "); } public static void printArray(int[] myArray) { for (int i = 0 ; i < myArray.length ; i++) { System.out.print(myArray[i] + " "); } /* Print for propper spacing */ System.out.println(" "); } public static void main(String[] args) { int[][] a = new int[10][5]; for (int i = 0 ; i < a.length ; i++) { for (int j = 0 ; j < a[i].length ; j++) { a[i][j] = 5; } } printArray(a); int[][] b; /* Array Copy */ b = a; System.out.println("Modfiying b "); b[0][1] = -1; /* Print a */ System.out.println("Printing array a"); printArray(a); /* Print b */ System.out.println("Printing array b"); printArray(b); int[] c; /* Array Copy */ c = b[3]; System.out.println("Modfiying c "); c[4] = 100; /* Print all arrays */ System.out.println("Printing array a"); printArray(a); System.out.println("Printing array b"); printArray(b); System.out.println("Printing array c"); printArray(c); } }
Exercise 2 Within the main method, create two char arrays. In the first array put your first name, in the second put your last: char O first = {'R', 'o,, 'b, , 'b, i', 'e') char last = {'G', 'i', 'f, 'f,'o','r','dy Create a third array that is a copy of the other two with interleaving letters. If your last or first name is much longer than the other, interleave them as much as you can
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
