Question: How can I make the following code print 1,2,3,2,2,2,2,2 How Can I make it so that each run through the for loop prints my fillWith

How can I make the following code print "1,2,3,2,2,2,2,2"

How Can I make it so that each run through the for loop prints my fillWith integer instead of zeros

package programming2020;

public class increaseAndFill {

public static void main(String[] args) { int [] numbers = {1,2,3}; numbers = increaseAndFill(numbers,5,2); for (int x: numbers) { System.out.println(x); }

} public static int[] increaseAndFill(int[] n,int increaseBy, int fillWith) { int[] newN= new int[n.length+increaseBy]; int y=0; for(int x=0; x

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!