JAVA_CODINGS Telegram 78
58. Merge two array.

class MergeArrayDemo
{
public static void main(String args[])
{
Integer a[]={1,2,3,4};
Integer b[]={5,6,7,0};
Integer[] both = concat(a, b);

System.out.print("\nFirst Array : ");
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+"\t");
}

System.out.print("\nSecond Array : ");
for(int i=0;i<b.length;i++)
{
System.out.print(b[i]+"\t");
}

System.out.print("\nMerged Array : ");
for(int i=0;i<both.length;i++)
{
System.out.print(both[i]+"\t");
}
}

public static Integer[] concat(Integer[] a, Integer[] b)
{
int aLen = a.length;
int bLen = b.length;
Integer[] c= new Integer[aLen+bLen];
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
}

@java_codings



tgoop.com/java_codings/78
Create:
Last Update:

58. Merge two array.

class MergeArrayDemo
{
public static void main(String args[])
{
Integer a[]={1,2,3,4};
Integer b[]={5,6,7,0};
Integer[] both = concat(a, b);

System.out.print("\nFirst Array : ");
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+"\t");
}

System.out.print("\nSecond Array : ");
for(int i=0;i<b.length;i++)
{
System.out.print(b[i]+"\t");
}

System.out.print("\nMerged Array : ");
for(int i=0;i<both.length;i++)
{
System.out.print(both[i]+"\t");
}
}

public static Integer[] concat(Integer[] a, Integer[] b)
{
int aLen = a.length;
int bLen = b.length;
Integer[] c= new Integer[aLen+bLen];
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Share with your friend now:
tgoop.com/java_codings/78

View MORE
Open in Telegram


Telegram News

Date: |

best-secure-messaging-apps-shutterstock-1892950018.jpg Step-by-step tutorial on desktop: More>> Healing through screaming therapy Hashtags
from us


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM American