YouTip LogoYouTip

Arrays Equal

# Java Example - Check if Arrays are Equal [![Image 3: Java Example](#) Java Example](#) The following example demonstrates how to use the equals() method to check if arrays are equal: ## Main.java File import java.util.Arrays; public class Main{public static void main(String[]args)throws Exception{int[]ary = {1,2,3,4,5,6}; int[]ary1 = {1,2,3,4,5,6}; int[]ary2 = {1,2,3,4}; System.out.println("Does array ary equal array ary1?? :" +Arrays.equals(ary, ary1)); System.out.println("Does array ary equal array ary2?? :" +Arrays.equals(ary, ary2)); }} The output of the above code is: Does array ary equal array ary1?? :trueDoes array ary equal array ary2?? :false [![Image 4: Java Example](#) Java Example](#)
← Python Sum DictionaryPython Slicing Rotate String β†’