the following program uses 2 arrays a & b of sizes m & n, both the arrays take values from user. third array is of size m+n. i hv to merge these two arrays into third one. but becoz of 1 error i m unable to do this. i hv tried a lot to solve this error.
i had shown u error by pointing on it.
package arrays;
import java.io.*;
class arrays
{
public static void main(String args[]) throws Exception
{
DataInputStream ds= new DataInputStream(System.in);
BufferedReader br= new BufferedReader(new InputStreamReader(ds));
int m,n,i;
System.out.println("Enter the size of first array");
m=Integer.parseInt(br.readLine());
int a[]= new int[m];
System.out.println("Enter"+m+"numbers");
for( i=0;i<=m-1;i++)
{
a[i]=Integer.parseInt(br.readLine());
}
System.out.println("Enter the size of second array");
n=Integer.parseInt(br.readLine());
int b[]= new int[n];
System.out.println("Enter"+n+"numbers");
for( i=0;i<=n-1;i++)
{
a[i]=Integer.parseInt(br.readLine());
}
int z=m+n;
int c[]= new int[z];
for( i=0;i<=z-1;i++)
{
if(i=m) // error, compiler says that here i&m should b of boolean type but found int type. but without int type i cnt solve dis query
{
c[i]=a[i];
}
else
{
c[i]=b[i-m];
}
}
for( i=0;i<=z-1;i++)
{
System.out.println(c[i]);
}
}
}