Check if two arrays are identical or not

Here given code implementation process.

/*
   Java program
   Check if two arrays are identical or not
*/
import java.util.HashMap;
import java.util.Map;
public class Comparison
{
    // Display value of given array
    public void displayArray(int []arr, int size)
    {
        for (int i = 0; i < size; ++i)
        {
            System.out.print(" " + arr[i]);
        }
        System.out.print("\n");
    }
    // Compare two given array 
    public void isEqualArrays(int[] arr1, int[] arr2)
    {
        int size1 = arr1.length;
        int size2 = arr2.length;
        boolean result = true;
        if (size1 != size2)
        {
            result = false;
        }
        else
        {
            // Define two maps
            Map < Integer, Integer > mp1 = new HashMap < > ();
            Map < Integer, Integer > mp2 = new HashMap < > ();
            // Insert array element into maps
            for (int i = 0; i < size1; i++)
            {
                if (mp1.containsKey(arr1[i]))
                {
                    // When key exist then put new value
                    mp1.put(arr1[i], mp1.get(arr1[i]) + 1);
                }
                else
                {
                    mp1.put(arr1[i], 1);
                }
                if (mp2.containsKey(arr2[i]))
                {
                    // when key exist then put new value
                    mp2.put(arr2[i], mp2.get(arr2[i]) + 1);
                }
                else
                {
                    mp2.put(arr2[i], 1);
                }
            }
            if (mp1.size() != mp2.size() || !mp1.equals(mp2))
            {
                result = false;
            }
        }
        // print array
        System.out.print("Array A \n");
        displayArray(arr1, size1);
        System.out.print("Array B \n");
        displayArray(arr2, size2);
        if (result == true)
        {
            System.out.print("Identical\n\n");
        }
        else
        {
            System.out.print("Not Identical\n\n");
        }
    }
    public static void main(String[] args)
    {
        Comparison task = new Comparison();

        // Define array elements
        int[] arr1 = {
            1 , 2 , 8 , 9 , 3 , 7 , 5 , 2
        };
        int[] arr2 = {
            9 , 7 , 8 , 5 , 2 , 1 , 3 , 2
        };
        int[] arr3 = {
            9 , 7 , 8 , 5 , 2 , 1 , 3 , 2 , 2 , 4
        };
        int[] arr4 = {
            9 , 4 , 8 , 5 , 2 , 1 , 3 , 2
        };
        int[] arr5 = {
            8 , 9 , 2 , 5 , 2 , 1 , 3 , 7
        };
        // Compare arr1 and arr2
        task.isEqualArrays(arr1, arr2);
        // Compare arr3 and arr4
        task.isEqualArrays(arr3, arr4);
        // Compare of arr1 and arr5
        task.isEqualArrays(arr1, arr5);
        // Compare arr1 and arr5
        task.isEqualArrays(arr4, arr5);
    }
}

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical
// Include header file
#include <iostream>
#include  <map>
using namespace std;

/*
   C++ program
   Check if two arrays are identical or not
*/

class Comparison
{
	public:
		// Display value of given array
		void displayArray(int arr[], int size)
		{
			for (int i = 0; i < size; ++i)
			{
				cout << " " << arr[i];
			}
			cout << "\n";
		}
	// Compare two given array
	void isEqualArrays(int arr1[], int arr2[],int size1,int size2)
	{

		bool result = true;
		if (size1 != size2)
		{
			result = false;
		}
		else
		{
			map < int, int > mp1 ;
			map < int, int > mp2 ;
			// Insert array element into maps
			for (int i = 0; i < size1; i++)
			{
				if (mp1.find(arr1[i]) != mp1.end())
				{
					mp1[arr1[i]] = mp1[arr1[i]] + 1;
				}
				else
				{
					mp1[arr1[i]] = 1;
				}
				if (mp2.find(arr2[i]) != mp2.end())
				{
					mp2[arr2[i]] = mp2[arr2[i]] + 1;
				}
				else
				{
					mp2[arr2[i]] = 1;
				}
			}
			if (mp1.size() != mp2.size() || !(mp1 == mp2))
			{
				result = false;
			}
		}
		//
		cout << "Array A \n";
		this->displayArray(arr1, size1);
		cout << "Array B \n";
		this->displayArray(arr2, size2);
		if (result == true)
		{
			cout << "Identical\n\n";
		}
		else
		{
			cout << "Not Identical\n\n";
		}
	}
};
int main()
{
	Comparison task = Comparison();
	// Define array elements
	int arr1[] = {
		1 , 2 , 8 , 9 , 3 , 7 , 5 , 2
	};
	int arr2[] = {
		9 , 7 , 8 , 5 , 2 , 1 , 3 , 2
	};
	int arr3[] = {
		9 , 7 , 8 , 5 , 2 , 1 , 3 , 2 , 2 , 4
	};
	int arr4[] = {
		9 , 4 , 8 , 5 , 2 , 1 , 3 , 2
	};
	int arr5[] = {
		8 , 9 , 2 , 5 , 2 , 1 , 3 , 7
	};
  	int s1 = sizeof(arr1) / sizeof(arr1[0]);
  	int s2 = sizeof(arr2) / sizeof(arr2[0]);
	// Compare arr1 and arr2
	task.isEqualArrays(arr1, arr2,s1,s2);
  
    s1 = sizeof(arr3) / sizeof(arr3[0]);
    s2 = sizeof(arr4) / sizeof(arr4[0]);
	// Compare arr3 and arr4
	task.isEqualArrays(arr3, arr4,s1,s2);
    
    s1 = sizeof(arr1) / sizeof(arr1[0]);
  	s2 = sizeof(arr5) / sizeof(arr5[0]);
	// Compare arr1 and arr5
	task.isEqualArrays(arr1, arr5,s1,s2);
  
    s1 = sizeof(arr4) / sizeof(arr4[0]);
  	s2 = sizeof(arr5) / sizeof(arr5[0]);
	// Compare arr1 and arr5
	task.isEqualArrays(arr4, arr5,s1,s2);
	return 0;
}

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical
// Include namespace system
using System;
using System.Collections.Generic;

/*
   C# program
   Check if two arrays are identical or not
*/
public class Comparison
{
	// Display value of given array
	public void displayArray(int[] arr, int size)
	{
		for (int i = 0; i < size; ++i)
		{
			Console.Write(" " + arr[i]);
		}
		Console.Write("\n");
	}
	public Boolean EqulaMaps(Dictionary < int, int > mp1, Dictionary < int, int > mp2)
	{
		foreach(var entry in mp1)
		{
		
			if (mp2.ContainsKey(entry.Key))
			{
				if (mp2[entry.Key] != entry.Value)
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		
		return true;
	}
	// Compare two given array
	public void isEqualArrays(int[] arr1, int[] arr2)
	{
		int size1 = arr1.Length;
		int size2 = arr2.Length;
		Boolean result = true;
		if (size1 != size2)
		{
			result = false;
		}
		else
		{
			// Define two maps
			Dictionary < int, int > mp1 = new Dictionary < int, int > ();
			Dictionary < int, int > mp2 = new Dictionary < int, int > ();
			// Insert array element into maps
			for (int i = 0; i < size1; i++)
			{
				if (mp1.ContainsKey(arr1[i]))
				{
					mp1[arr1[i]] += 1;
				}
				else
				{
					mp1.Add(arr1[i], 1);
				}
				if (mp2.ContainsKey(arr2[i]))
				{
					mp2[arr2[i]] += 1;
				}
				else
				{
					mp2.Add(arr2[i], 1);
				}
			}
			if (mp1.Count != mp2.Count || EqulaMaps(mp1, mp2) == false 
                                       )
			{
				result = false;
			}
		}
		// Display given array
		Console.Write("Array A \n");
		displayArray(arr1, size1);
		Console.Write("Array B \n");
		displayArray(arr2, size2);
		if (result == true)
		{
			Console.Write("Identical\n\n");
		}
		else
		{
			Console.Write("Not Identical\n\n");
		}
	}
	public static void Main(String[] args)
	{
		Comparison task = new Comparison();
		// Define array elements
		int[] arr1 = {
			1 , 2 , 8 , 9 , 3 , 7 , 5 , 2
		};
		int[] arr2 = {
			9 , 7 , 8 , 5 , 2 , 1 , 3 , 2
		};
		int[] arr3 = {
			9 , 7 , 8 , 5 , 2 , 1 , 3 , 2 , 2 , 4
		};
		int[] arr4 = {
			9 , 4 , 8 , 5 , 2 , 1 , 3 , 2
		};
		int[] arr5 = {
			8 , 9 , 2 , 5 , 2 , 1 , 3 , 7
		};
		// Compare arr1 and arr2
		task.isEqualArrays(arr1, arr2);
		// Compare arr3 and arr4
		task.isEqualArrays(arr3, arr4);
		// Compare arr1 and arr5
		task.isEqualArrays(arr1, arr5);
		// Compare arr1 and arr5
		task.isEqualArrays(arr4, arr5);
	}
}

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical
<?php
/*
   Php program
   Check if two arrays are identical or not
*/
class Comparison
{
	// Display value of given array
	public	function displayArray( $arr)
	{
      	$size = count($arr);
		for ($i = 0; $i < $size; ++$i)
		{
			echo " ". $arr[$i];
		}
		echo "\n";
	}
	// Compare two given array
	public function isEqualArrays( $arr1, $arr2)
	{
		echo "Array A \n";
		$this->displayArray($arr1);
		echo "Array B \n";
		$this->displayArray($arr2);
      	// Sort local array
      	sort($arr1);
      	sort($arr2);
		if ($arr1 == $arr2)
		{
			echo "Identical\n\n";
		}
		else
		{
			echo "Not Identical\n\n";
		}
	}
}

function main()
{
	$task = new Comparison();
	// Define array elements
	$arr1 = array(1, 2, 8, 9, 3, 7, 5, 2);

	$arr2 = array(9, 7, 8, 5, 2, 1, 3, 2);
	$arr3 = array(9, 7, 8, 5, 2, 1, 3, 2, 2, 4);
	$arr4 = array(9, 4, 8, 5, 2, 1, 3, 2);
	$arr5 = array(8, 9, 2, 5, 2, 1, 3, 7);
	// Compare arr1 and arr2
	$task->isEqualArrays($arr1, $arr2);
	// Compare arr3 and arr4
	$task->isEqualArrays($arr3, $arr4);
	// Compare arr1 and arr5
	$task->isEqualArrays($arr1, $arr5);
	// Compare arr1 and arr5
	$task->isEqualArrays($arr4, $arr5);
}
main();

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical
/*
   Node Js program
   Check if two arrays are identical or not
*/
class Comparison
{
	// Display value of given array
	displayArray(arr, size)
	{
		for (var i = 0; i < size; ++i)
		{
			process.stdout.write(" " + arr[i]);
		}
		process.stdout.write("\n");
	}
  mapEquals(map1, map2)
{ // Compare size
	if (map1.size !== map2.size)
	{
		return false;
	}
	var temp;
	for (var [key, val] of map1)
	{
		// Get map2 key value
		temp = map2.get(key);
		if (temp !== val || (temp === undefined && map2.has(key) == false))
		{
			return false;
		}
	}
	return true;
}
	// Compare two given array
	isEqualArrays(arr1, arr2)
	{
		let diff = arr1.filter(x => !arr2.includes(x))
                 .concat(arr2.filter(x => !arr1.includes(x)));
     
		var size1 = arr1.length;
		var size2 = arr2.length;
	
		// Display given array
		process.stdout.write("Array A \n");
		this.displayArray(arr1, size1);
		process.stdout.write("Array B \n");
		this.displayArray(arr2, size2);
		if (diff.length == 0)
		{
			console.log("Identical\n");
		}
		else
		{
			console.log("Not Identical\n");
		}
	}
}

function main()
{
	var task = new Comparison();
	// Define array elements
	var arr1 = [1, 2, 8, 9, 3, 7, 5, 2];
	var arr2 = [9, 7, 8, 5, 2, 1, 3, 2];
	var arr3 = [9, 7, 8, 5, 2, 1, 3, 2, 2, 4];
	var arr4 = [9, 4, 8, 5, 2, 1, 3, 2];
	var arr5 = [8, 9, 2, 5, 2, 1, 3, 7];
	// Compare arr1 and arr2
	task.isEqualArrays(arr1, arr2);
	// Compare arr3 and arr4
	task.isEqualArrays(arr3, arr4);
	// Compare arr1 and arr5
	task.isEqualArrays(arr1, arr5);
	// Compare arr1 and arr5
	task.isEqualArrays(arr4, arr5);
}
main();

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical
#    Python 3 program
#    Check if two arrays are identical or not
import collections 
class Comparison :
    
    #  Compare two given list 
    def isEqualList(self, arr1, arr2) :
        size1 = len(arr1)
        size2 = len(arr2)

        #  Display given list
        print("List A ")
        print(arr1)
        print("List B ")
        print(arr2)
        if (collections.Counter(arr1) == collections.Counter(arr2)) :
            print("Identical\n")
        else :
            print("Not Identical\n")


def main() :
    task = Comparison()
    #  Define list elements
    arr1 = [1, 2, 8, 9, 3, 7, 5, 2]
    arr2 = [9, 7, 8, 5, 2, 1, 3, 2]
    arr3 = [9, 7, 8, 5, 2, 1, 3, 2, 2, 4]
    arr4 = [9, 4, 8, 5, 2, 1, 3, 2]
    arr5 = [8, 9, 2, 5, 2, 1, 3, 7]
    #  Compare arr1 and arr2
    task.isEqualList(arr1, arr2)
    #  Compare arr3 and arr4
    task.isEqualList(arr3, arr4)
    #  Compare arr1 and arr5
    task.isEqualList(arr1, arr5)
    #  Compare arr1 and arr5
    task.isEqualList(arr4, arr5)

if __name__ == "__main__": main()

Output

List A
[1, 2, 8, 9, 3, 7, 5, 2]
List B
[9, 7, 8, 5, 2, 1, 3, 2]
Identical

List A
[9, 7, 8, 5, 2, 1, 3, 2, 2, 4]
List B
[9, 4, 8, 5, 2, 1, 3, 2]
Not Identical

List A
[1, 2, 8, 9, 3, 7, 5, 2]
List B
[8, 9, 2, 5, 2, 1, 3, 7]
Identical

List A
[9, 4, 8, 5, 2, 1, 3, 2]
List B
[8, 9, 2, 5, 2, 1, 3, 7]
Not Identical
# 
#    Ruby program
#    Check if two arrays are identical or not

class Comparison 
	#  Display value of given array
	def displayArray(arr, size) 
		i = 0
		while (i < size) 
			print(" ", arr[i])
			i += 1
		end

		print("\n")
	end

	#  Compare two given array
	def isEqualArrays(arr1, arr2) 
		size1 = arr1.length
		size2 = arr2.length
	
		#  Display given array
		print("Array A \n")
		self.displayArray(arr1, size1)
		print("Array B \n")
		self.displayArray(arr2, size2)
		if (arr1.sort == arr2.sort) 
			print("Identical\n\n")
		else 
			print("Not Identical\n\n")
		end

	end

end

def main() 
	task = Comparison.new()
	#  Define array elements
	arr1 = [1, 2, 8, 9, 3, 7, 5, 2]
	arr2 = [9, 7, 8, 5, 2, 1, 3, 2]
	arr3 = [9, 7, 8, 5, 2, 1, 3, 2, 2, 4]
	arr4 = [9, 4, 8, 5, 2, 1, 3, 2]
	arr5 = [8, 9, 2, 5, 2, 1, 3, 7]
	#  Compare arr1 and arr2
	task.isEqualArrays(arr1, arr2)
	#  Compare arr3 and arr4
	task.isEqualArrays(arr3, arr4)
	#  Compare arr1 and arr5
	task.isEqualArrays(arr1, arr5)
	#  Compare arr1 and arr5
	task.isEqualArrays(arr4, arr5)
end

main()

Output

Array A 
 1 2 8 9 3 7 5 2
Array B 
 9 7 8 5 2 1 3 2
Identical

Array A 
 9 7 8 5 2 1 3 2 2 4
Array B 
 9 4 8 5 2 1 3 2
Not Identical

Array A 
 1 2 8 9 3 7 5 2
Array B 
 8 9 2 5 2 1 3 7
Identical

Array A 
 9 4 8 5 2 1 3 2
Array B 
 8 9 2 5 2 1 3 7
Not Identical

/*
   Scala program
   Check if two arrays are identical or not
*/
class Comparison
{
	// Display value of given array
	def displayArray(arr: Array[Int], size: Int): Unit = {
		var i: Int = 0;
		while (i < size)
		{
			print(" " + arr(i));
			i += 1;
		}
		print("\n");
	}
	// Compare two given array
	def isEqualArrays(arr1: Array[Int], arr2: Array[Int]): Unit = {
		var size1: Int = arr1.length;
		var size2: Int = arr2.length;
		
		// Display given array
		print("Array A \n");
		this.displayArray(arr1, size1);
		print("Array B \n");
		this.displayArray(arr2, size2);
		scala.util.Sorting.quickSort(arr1);
		scala.util.Sorting.quickSort(arr2);
		if ((arr1) sameElements (arr2))
		{
			print("Identical\n\n");
		}
		else
		{
			print("Not Identical\n\n");
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: Comparison = new Comparison();
		// Define array elements
		var arr1: Array[Int] = Array(1, 2, 8, 9, 3, 7, 5, 2);
		var arr2: Array[Int] = Array(9, 7, 8, 5, 2, 1, 3, 2);
		var arr3: Array[Int] = Array(9, 7, 8, 5, 2, 1, 3, 2, 2, 4);
		var arr4: Array[Int] = Array(9, 4, 8, 5, 2, 1, 3, 2);
		var arr5: Array[Int] = Array(8, 9, 2, 5, 2, 1, 3, 7);
		// Compare arr1 and arr2
		task.isEqualArrays(arr1, arr2);
		// Compare arr3 and arr4
		task.isEqualArrays(arr3, arr4);
		// Compare arr1 and arr5
		task.isEqualArrays(arr1, arr5);
		// Compare arr1 and arr5
		task.isEqualArrays(arr4, arr5);
	}
}

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 2 3 5 7 8 9
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 1 2 2 3 4 5 8 9
Array B
 1 2 2 3 5 7 8 9
Not Identical
/*
   Swift 4 program
   Check if two arrays are identical or not
*/
class Comparison
{
	// Display value of given array
	func displayArray(_ arr: [Int], _ size: Int)
	{
		var i: Int = 0;
		while (i < size)
		{
			print(" ", arr[i], terminator: "");
			i += 1;
		}
		print(terminator: "\n");
	}
	// Compare two given array
	func isEqualArrays(_ arr1: [Int], _ arr2: [Int])
	{
		let size1: Int = arr1.count;
		let size2: Int = arr2.count;
		var result: Bool = true;
       	let a = arr1.sorted();
 		let b = arr2.sorted();
		if (size1  != size2 || a  != b)
		{
			result = false;
		}
		// Display given array
		print("Array A ");
		self.displayArray(arr1, size1);
		print("Array B ");
		self.displayArray(arr2, size2);
		if (result == true)
		{
			print("Identical\n");
		}
		else
		{
			print("Not Identical\n");
		}
	}
}
func main()
{
	let task: Comparison = Comparison();
	// Define array elements
	let arr1: [Int] = [1, 2, 8, 9, 3, 7, 5, 2];
	let arr2: [Int] = [9, 7, 8, 5, 2, 1, 3, 2];
	let arr3: [Int] = [9, 7, 8, 5, 2, 1, 3, 2, 2, 4];
	let arr4: [Int] = [9, 4, 8, 5, 2, 1, 3, 2];
	let arr5: [Int] = [8, 9, 2, 5, 2, 1, 3, 7];
	// Compare arr1 and arr2
	task.isEqualArrays(arr1, arr2);
	// Compare arr3 and arr4
	task.isEqualArrays(arr3, arr4);
	// Compare arr1 and arr5
	task.isEqualArrays(arr1, arr5);
	// Compare arr1 and arr5
	task.isEqualArrays(arr4, arr5);
}
main();

Output

Array A
  1  2  8  9  3  7  5  2
Array B
  9  7  8  5  2  1  3  2
Identical

Array A
  9  7  8  5  2  1  3  2  2  4
Array B
  9  4  8  5  2  1  3  2
Not Identical

Array A
  1  2  8  9  3  7  5  2
Array B
  8  9  2  5  2  1  3  7
Identical

Array A
  9  4  8  5  2  1  3  2
Array B
  8  9  2  5  2  1  3  7
Not Identical
/*
   Kotlin program
   Check if two arrays are identical or not
*/
class Comparison
{
	// Display value of given array
	fun displayArray(arr: Array < Int > , size: Int): Unit
	{
		var i: Int = 0;
		while (i < size)
		{
			print(" " + arr[i]);
			i += 1;
		}
		print("\n");
	}
	// Compare two given array
	fun isEqualArrays(arr1: Array < Int > , arr2: Array < Int > ): Unit
	{
		var size1: Int = arr1.count();
		var size2: Int = arr2.count();
		var result: Boolean = true;
		if (size1 != size2)
		{
			result = false;
		}
		else
		{
			// Define two maps
			var mp1 = mutableMapOf<Int, Int>()
			var mp2 = mutableMapOf<Int, Int>()
			// Insert array element into maps
			var i: Int = 0;
			while (i < size1)
			{
				if (mp1.containsKey(arr1[i]))
				{
					mp1.put(arr1[i], mp1.getValue(arr1[i]) + 1);
				}
				else
				{
					mp1.put(arr1[i], 1);
				}
				if (mp2.containsKey(arr2[i]))
				{
					mp2.put(arr2[i], mp2.getValue(arr2[i]) + 1);
				}
				else
				{
					mp2.put(arr2[i], 1);
				}
				i += 1;
			}
			if (mp1.size != mp2.size || !(mp1 == mp2))
			{
				result = false;
			}
		}
		// Display given array
		print("Array A \n");
		this.displayArray(arr1, size1);
		print("Array B \n");
		this.displayArray(arr2, size2);
		if (result == true)
		{
			print("Identical\n\n");
		}
		else
		{
			print("Not Identical\n\n");
		}
	}
}
fun main(args: Array < String > ): Unit
{
	var task: Comparison = Comparison();
	// Define array elements
	var arr1: Array < Int > = arrayOf(1, 2, 8, 9, 3, 7, 5, 2);
	var arr2: Array < Int > = arrayOf(9, 7, 8, 5, 2, 1, 3, 2);
	var arr3: Array < Int > = arrayOf(9, 7, 8, 5, 2, 1, 3, 2, 2, 4);
	var arr4: Array < Int > = arrayOf(9, 4, 8, 5, 2, 1, 3, 2);
	var arr5: Array < Int > = arrayOf(8, 9, 2, 5, 2, 1, 3, 7);
	// Compare arr1 and arr2
	task.isEqualArrays(arr1, arr2);
	// Compare arr3 and arr4
	task.isEqualArrays(arr3, arr4);
	// Compare arr1 and arr5
	task.isEqualArrays(arr1, arr5);
	// Compare arr1 and arr5
	task.isEqualArrays(arr4, arr5);
}

Output

Array A
 1 2 8 9 3 7 5 2
Array B
 9 7 8 5 2 1 3 2
Identical

Array A
 9 7 8 5 2 1 3 2 2 4
Array B
 9 4 8 5 2 1 3 2
Not Identical

Array A
 1 2 8 9 3 7 5 2
Array B
 8 9 2 5 2 1 3 7
Identical

Array A
 9 4 8 5 2 1 3 2
Array B
 8 9 2 5 2 1 3 7
Not Identical


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved