1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nonamiya [84]
3 years ago
12

Write the following method that merges two sorted arrays into a new sorted array public static int [] merge(int [] array1, int [

] array2) { // add your code here } public static void main(String [] args) { int [] array1 = {1, 5, 16, 61, 111}; int [] array 2 = {2, 4, 5, 6} int [] mergedArray = merge(array1, array2); System.out.println(Arrays.toString(mergedArray)); } java doc
Computers and Technology
1 answer:
uysha [10]3 years ago
7 0

Answer:

See explaination

Explanation:

import java.util.Arrays;

public class MergeArrays {

public static int[] merge(int[] array1, int[] array2) {

int[] result = new int[array1.length + array2.length];

int i = 0, j = 0, k = 0;

while (i < array1.length && j < array2.length) {

if (array1[i] < array2[j]) result[k++] = array1[i++];

else result[k++] = array2[j++];

}

while (i < array1.length) result[k++] = array1[i++];

while (j < array2.length) result[k++] = array2[j++];

return result;

}

public static void main(String[] args) {

int[] array1 = {1, 5, 16, 61, 111};

int[] array2 = {2, 4, 5, 6};

int[] mergedArray = merge(array1, array2);

System.out.println(Arrays.toString(mergedArray));

}

}

You might be interested in
In this exercise, you will write a class that represents how you spend your time during the week The class should have four doub
Nuetrik [128]

Answer:

Answered below

Explanation:

# Program is written in Java

class WeekHours{

double school;

double fun;

double sleep;

double sports;

WeekHours( ){

school = 0.0;

fun = 0.0;

sleep = 0.0;

sports = 0.0;

}

public void setSchool ( double x){

school = x;

}

public void setFun( double y){

fun = y;

}

public void setSleep( double w){

sleep = w;

}

public void setSports( double z){

sports = z;

}

public void totalHours(){

double tHours = school + fun + sleep + sports;

System.out.print(tHours);

}

}

4 0
3 years ago
To provide for unobtrusive validation, you can install the ____________________ package for unobtrusive validation.
NARA [144]

Answer:

AspNet.ScriptManager.jQuery?

Explanation:

Unobtrusive validation means we can perform a simple client-side validation without writing a lot of validation code by adding suitable attributes and also by including the suitable script files.

One of the benefits of using a unobtrusive validation is that it help to reduce the amount of the Java script that is generated. We can install the AspNet.ScriptManager.jQuery? for the unobtrusive validation.

When the unobtrusive validation is used, validation of the client is being performed by using a JavaScript library.

4 0
3 years ago
I still need help, thank you! Will give Brainliest ​
wlad13 [49]

Answer: 1 what do u think to help u

6 0
3 years ago
Why is the keyboard calledQWERTY
taurus [48]
The standard QWERTY layout keyboard is called 'QWERTY' because on the top line of the keyboard the first 6 letters from chronological left to right order are; Q, W, E, R, T, and Y.

Or...if you're wondering why it's QWERTY and not ABCDEF, it's because when typing with the alphabetical format, many of the keys would clash with each other due to the arrangement of keys on the original typewriter. The QWERTY layout became so popular, it was the standardized layout for typewriters, and even keyboards today.
4 0
3 years ago
Read 2 more answers
What is a computer software?​
Fofino [41]

Answer:

Software, instructions that tell a computer what to do The term was coined to differentiate these instructions from hardware  the physical components of a computer system.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • When using presentation aids A. make the aid available for the audience to look at throughout the speech. B. prepare to give you
    6·1 answer
  • But this time use 16 kib pages instead of 4 kib pages. what would be some of the advantages of having a larger page size? what a
    11·1 answer
  • When using the red / yellow / green method to present status of a project, yellow can mean which of the following? A. There are
    5·2 answers
  • Which items may interfere with a wireless connection and may cause disruptions or delays in submitting assignments in blackboard
    9·2 answers
  • Which are the benefits of leveraging web technologies?
    8·2 answers
  • Which ofthe following sentence beginnings would be best to use in apersuasive request?
    8·1 answer
  • If you want to present slides to fellow students or coworkers which productivity software should you use to create them A. Word
    14·2 answers
  • Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, s
    11·1 answer
  • Which of the following is not a language commonly used for web programming?
    8·2 answers
  • Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, et
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!