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 08:30
1.the index finger on your right hand types the f r v 4 j u m 7 h y 6 n lo.9 j u 7 m g t 5 b 2.if you need to multiply 400, 2, and 1 ½, what would you type on the numeric keypad? 400*2*1.5 400/2*1.5 400/2/1.5 400*2*1½ 3.select all examples of proper keyboarding technique. rest your fingers gently on the home row or home keys. slouch in your chair. rest your palms on the keyboard. relax your fingers. keep your hands lower than your elbows.
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
question
Computers and Technology, 24.06.2019 00:30
Afiling system in which an intermediary source of reference, such as a file card, must be consulted to locate specific files is called a(n) system. a. shelf filing b. direct filing c. indirect filing d. shingling
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
question
Chemistry, 14.07.2020 23:01
question
Mathematics, 14.07.2020 23:01
question
Mathematics, 14.07.2020 23:01
question
Social Studies, 14.07.2020 23:01
Questions on the website: 13722367