Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9 printArray(myArray, " - ") will print out 1 - 22 - 333 - 400 - 5005 - 9 You may wish to write some additional code to test your method. -------------------------------------------------- // import any necessary packages here below public class Main { public static void main(String[] args) { // write any code to test you method(s) here below } // define your method(s) here below }
Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument.
For example, given the following Array declaration and instantiation:
int[] myArray = {1, 22, 333, 400, 5005, 9};
printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9
printArray(myArray, " - ") will print out 1 - 22 - 333 - 400 - 5005 - 9
You may wish to write some additional code to test your method.
--------------------------------------------------
// import any necessary packages here below
public class Main {
public static void main(String[] args) {
// write any code to test you method(s) here below
}
// define your method(s) here below
}
![Main.java
Load default template...
1 // import any necessary packages here below
2
3 public class Main {
public static void main(String[] args) {
// write any code to test you method(s) here below
int] myArray
}
4
6.
{1, 22, 333, 400, 5005, 9};
7
8
public static void printArray(int myarr[], String s){
for(int i = 0; i< myarr.length ;i++){
System.out.print(myarr[i]+s);
}
}
9.
10
11
12
13
14
15 }
When done developing your program, press the Submit for grading button below. This will
submit your program for auto-grading.
Develop mode
Submit mode
Submit for grading
Coding trail of your work
What is this?
3/27 U-40,40,40,40,40,0,40,40 min:6
Latest submission - 2:28 PM MST on 03/27/22
Total score: 40 / 100
Only show failing tests
Download this submission
1: Structure Test a
40 / 40](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F11d04d1b-414c-4e30-b9e8-ca86d6b26e1f%2F0d05e101-e2c3-476d-b711-2cb3c031cd4a%2F4qigkq5_processed.png&w=3840&q=75)
![Latest submission - 2:28 PM MST on 03/27/22
Total score: 40 / 100
Only show failing tests
Download this submission
1: Structure Test a
40 / 40
Test feedback
PASS
public static void printArray(int[],String) method found.
2: Logic test 1 ^
0/ 30
printArray(myArray, ", ")` should print out `1, 22, 333, 400, 5005, 9`
FAIL
incorrect output
expected :
1, 22, 333, 400, 5005, 9
Test feedback
but got
:
1, 22, 333, 400, 5005, 9,
3: Logic test 2 ^
0/30
"printArray(myArray, " - ")` should print out `1 - 22 - 333 - 400 - 5005 - 9`
II
FAIL
incorrect output
expected :
1
22
333
400
5005
Test feedback
but got
:
1
22
333
400 -
5005
-](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F11d04d1b-414c-4e30-b9e8-ca86d6b26e1f%2F0d05e101-e2c3-476d-b711-2cb3c031cd4a%2Fm61i2yu_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









