Tuesday, October 5, 2021

 


Java Program: Take 2 arrays, write a method to - Insert array2 in to array1 at given position

//Output: {12, 13,14,5,6,15}


package qasign;

import java.util.ArrayList;

import java.util.Arrays;

public class SampleTest {

public static void main(String[] args) {

Integer array1[]={12, 13,14,15};

Integer array2[]={5, 6};

int position=3;

List<Integer> list1=new ArrayList<>(Arrays.asList(array1));

System.out.println();

Arrays.asList(array2);

List<Integer> list2=new ArrayList<>(Arrays.asList(array2));

list1.addAll(position, list2);

System.out.println(list1);

}

}

0 comments:

Post a Comment

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts