Single array tutorial evaluation of elements


Hello everyone, in this tutorial we will learn something new in java programming, the codes below will definitely show you, how to evaluate a set of single array whether the elements of the first array and second array are equal or not, so below is the perfect demonstration of evaluating the two sets of a single array, have a look and test the codes below and see the results, and don't forget to write your question or in the comment section, have a good day.
import java.util.Arrays;
import java.io.*; public class Array4{
public static void main (String args[])throws IOException{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter 1st set");
int a = Integer.parseInt(input.readLine());
int has[] = new int [a];
System.out.println("Enter 2nd sets");
int b = Integer.parseInt(input.readLine());
int san[] = new int [b];
for(int i=0;i<has.length;i++){
System.out.println("Enter 1st set of numbers");
has[i] = Integer.parseInt(input.readLine());
}
System.out.println("set 1"+Arrays.toString(has));
for(int o=0;o<san.length;o++){
System.out.println("Enter 2nd set of numbers");
san[o] = Integer.parseInt(input.readLine());
}
System.out.println("set 2"+Arrays.toString(san));
if(has.length==san.length){
System.out.println("the two sets are equal");
}
else if(has.length!=san.length){
System.out.println("the two sets are not equal");
}   }
}

  

Post a Comment

0 Comments