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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started