Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JoinArrays) Write a method, joinArrays, which receives two ArrayList of Integer, and concatenates them (joins them together to make one, larger array). The method will

image text in transcribed
image text in transcribed
image text in transcribed
(JoinArrays) Write a method, joinArrays, which receives two ArrayList of Integer, and concatenates them (joins them together to make one, larger array). The method will not alter the two original ArrayLists but will return a new ArrayList of Integer Example: X5 4 3 2 1 y 8 7 6 Z joinArrays (x,y) will return a new array as follows. 5 4 3 2 1 8 7 6 Sample Output: 2, 1 Original arrays: Array: 5, 4, 3, Array: 8, 7, 6 Result of join(x,y). Array: 5, 4, 3, 2. 1, 8, 7. 6 mport java.util.*; ublic class JoinArrays public static void main(String[] args) { ArrayList X = new ArrayList(); ArrayList y = new ArrayList(); ArrayList z; int i; for(i=5; i >0; i--) x.add(i); for( i=8; i >=6; i--) y.add(i); System.out.println("Original arrays:"); display(); display(y): z = joinArrays(x, y): System.out.println("Result of join(x,y)."): display(); } private static void display( ArrayList x) { System.out.println("Original arrays:"); display(); display(y): z = joinArrays(x, y): System.out.println("Result of join(x,y)."); display(z); } private static void display( ArrayList x) { int i; System.out.print("Array: "); for(i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago