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
Get step-by-step solutions from verified subject matter experts
