Tue Nov 11, 2008 10:42 pm
import java.io.*;
import java.util.*;
public class ComparingArrays{
public static void main(String[] args) throws IOException{
int[] array1 = new int[5];
int[] array2 = new int[5];
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.println("Enter 5 numbers for the first Array : ");
for(int i = 0; i < array1.length; i++){
array1[i] = Integer.parseInt(in.readLine());
}
System.out.println("Enter 5 numbers for the second Array : ");
for(int i = 0; i < array2.length; i++){
array2[i] = Integer.parseInt(in.readLine());
}
}
catch(NumberFormatException ne){
ne.printStackTrace();
}
boolean check = Arrays.equals(array1, array2);
if(check == false)
System.out.println("Arrays are not same.");
else
System.out.println("Both Arrays are same.");
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.