subject

I am in an Intro to Java class. We were instructed to create a code using multidimensional arrays that would produce the output: [5, 6, 7, 8]
[
[2, 4, 6, 8]
[8, 7, 9, 1]
[3, 5, 1, 2]
]

[
[1, 2]
[3, 4, 5]
[6]
[7, 8, 9]
]

I’ve been working on it, but have gotten stuck. If anyone could finish my code, and point out where I’m going wrong, I would greatly appreciate it. Here’s my code:

public class ArrayPrinter{

public static void main(String[]args) {
int[] oneD = {5, 6, 7, 8};
printArray(oneD);
System. out. println();
int[][] twoD = {{2, 4, 6, 8},
{8, 7, 9, 1},
{3, 5, 1, 2}};
printArray(twoD);
System. out. println();
int[][] twoD2 = {{1, 2},
{3, 4, 5},
{6},
{7, 8, 9}};
printArray(twoD2);

}

public static void printArray(int[] arr) {
System. out. print("[");
for(int i = 0; i < arr. length; i++) {
System. out. print(arr. length);
if(i < arr. length -1) {
System. out. print(" ");
}}

}
public static void printArray (int[][] arr) {
for (int i=0; i < arr. length; i++) {
System. out. print(arr[i] + " ");
}
}
public static void printArray(int[][][] arr) {

System. out. println(" ");

System. out. println("]");
printArray(arr[i]);

System. out. println("]");

System. out. println("]");
}}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 02:40, homework1911
Has anyone seen my grandma shes been gone for 4 years already
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, BobBball9126
How do you share someone else’s tweet with your own twitter followers?
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, pineapplefun
During the software planning process, rick, a project manager, finds that his team has made an incorrect estimation of funds. what kind of risk has rick identified? rick has identified a risk.
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, altstattlana
Read these lines from beowulf. often scyld scefing seized mead-benches from enemytroops, from many a clan, he terrified warriors, even thoughfirst he was found a waif, best explains why the author includes this information in theexposition? a. to emphasize that a hero must learn to be fierceb. to remember the famous story of a popular heroc. to express sadness about losing the old heroesd. to see whether people still respect the old heroes
Answers: 1
You know the right answer?
I am in an Intro to Java class. We were instructed to create a code using multidimensional arrays th...

Questions in other subjects:

Konu
Mathematics, 14.09.2020 04:01
Konu
Biology, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01
Konu
Mathematics, 14.09.2020 04:01