Question: add_to_r is a method that gets an array and a number. the method creates a new array bigger by one then (int[] r). It populates

add_to_r is a method that gets an array and a number.

the method creates a new array bigger by one then (int[] r).

It populates the new array with the old ones(r) values.

and finally in the last position adds the number (int n) to it.

for example:

method input: add_to_r(new int{1,5,77,8} ,2)

outputs (int array):

[1, 5, 77, 8, 2]

Note: In main method create an array and populate it with the values {1,5,77,8}. Call the method add_to_r and pass the created array and 2 as a parameters. Print the result.

---------------------------------------------

import java.util.*; import java.util.Arrays;

class Main { public static int[] add_to_r(int[] initialArray,int newNumber) { //create new array with one more position. return null; } public static void main(String[] args) { //Your code Here

} }

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!