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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:00
Ahorse is how much percent more powerful than a pony
Answers: 1
question
Computers and Technology, 23.06.2019 08:30
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
question
Computers and Technology, 24.06.2019 10:30
Which of the following types of software is most applicable to the promotion of new products through advertising? a.databases b. spreadsheets c. web design programs d. word processing tools
Answers: 2
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
question
Mathematics, 24.12.2019 06:31
question
Health, 24.12.2019 06:31
Questions on the website: 13722362