00:01
In this question, we are going to solve a question and write the code in java.
00:08
So let us look at the steps that we are going to follow.
00:11
The first thing that we will do is we will break down the code for createnewarray.
00:18
So we will see what createnewarray exactly is.
00:28
So the first thing is that what is this exactly? so this is a function that we are going to be using and it will be having the two parameters that is arr and the second parameter is func, that is a function.
00:54
So the function is intended to create a new array containing the result of applying the provided function to each element in the input array.
01:09
So what we do is we initialize an empty array which is called as the result array.
01:19
So this result array that we initialize will be an empty array.
01:30
Now we see that we start a for loop for which we try to iterate through each element in the arr.
01:43
So that is the input array.
01:46
So we use the arr .length and to determine the number of elements in the array, we use i as the loop counter.
02:02
So now we will have a look at, so there will be certain functions inside this loop.
02:08
So we will have a look at it in the basic java compiler.
02:13
So first thing that we will be doing while solving this code or writing this code is that we will be initializing an array and also an empty array.
02:28
So first thing is we initialize the create new array that we just discussed and we have given it the two parameters that is arr, that is an array and func, that is a function...