Create a class called CompareArrays that determines if two specified integer arrays are equal.
The class should have one static methods:
Create a second class called CompareArraysTest that contains the main method, and thoroughly tests the ComparyArrays.compare method. This test class does not need to ask users for input. Just create the needed arrays to ensure that you test the ComparyArrays.compare method well
class CompareArrays {
public static boolean compare(int[] arrayOne, int[]
arrayTwo) {
// checking if lengths are
different than it is false
if (arrayOne.length !=
arrayTwo.length)
return
false;
// iterating 2 arrays
// comparing each element
for (int i = 0; i <
arrayOne.length; i++)
if (arrayOne[i]
!= arrayTwo[i])
return false;
return true;
}
}
public class CompareArraysTest {
public static void main(String[] args) {
// creating 4 arrays
int arr1[] = { 1, 2, 3 };
int arr2[] = { 1, 2, 3 };
int arr3[] = { 1, 5, 6 };
int arr4[] = { 11, 15, 16 };
// comparing 1 and 2
System.out.println(CompareArrays.compare(arr1, arr2));
// comparing 3 and 4
System.out.println(CompareArrays.compare(arr3, arr4));
}
}

Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Create a class called CompareArrays that determines if two specified integer arrays are equal. The class...
Create a class called CompareArrays that determines if two specified integer arrays are equal. The class should have one static methods: public static boolean compare(int[] arrayOne, int[] arrayTwo) – Which compares the two arrays for equality. The two arrays are considered equal if they are the same size, and contain the same elements in the same order. If they are equal, the method should return true. Otherwise, the method should return false. Create a second class called CompareArraysTest that contains...
Java:
Create the skeleton.
Create a new file called ‘BasicJava4.java’
Create a class in the file with the appropriate name.
public class BasicJava4 {
Add four methods to the class that return a default value.
public static boolean isAlphabetic(char aChar)
public static int round(double num)
public static boolean useSameChars(String str1, String
str2)
public static int reverse(int num)
Implement the methods.
public static boolean isAlphabetic(char aChar):
Returns true if the argument is an alphabetic character, return
false otherwise. Do NOT use...
Create a class called Reverse that reverses an array of integers. The class should have two method: - public static void reverse(int [] array) – Which calls the private recursive method, passing the array parameter and which two array elements should be swapped. - private static void reverseRecursive(int [] array, int startIndex, int endIndex) – Which swaps the two elements of the array parameter pointed to by the startIndex and endIndex parameters. The method should be called again, this time,...
Create a class called AddressBook. It should be able to store a maximum of 50 names and 50 phone numbers (make an array of structures in the object or two arrays). It should contain a method called addName that will take a name and phone number and add it to the address book. There should be a method called findName that will take a string for the name and return the phone number if found in the list otherwise return...
Static methods can be called directly from the name of the class that contains the method. Static methods are usually created to do utility operations. For example: public class Test{ public static int timesTwo(int value){ return value * value; } } public class TestDriver{ public static void main(String[] args){ int var = Test.timesTwo(5); System.out.println(var); } } For your final exercise, create a class called ManyLinkedLists. It will contain a static method called createLinkedList(). That method takes an argument that is...
Create a new class called DemoSortingPerformacne Create a private method called getRandomNumberArray. It returns an array of Integer and has 2 parameters: arraySize of type int and numberOfDigits of type int. This method should create an array of the specified size that is filled with random numbers. Each random numbers should have the same number of digits as specified in the second parameter In your main method (or additional private methods) do the following: Execute selection sort on quick sort...
Static methods can be called directly from the name of the class that contains the method. Static methods are usually created to do utility operations. For example: public class Test{ public static int timesTwo(int value){ return value * value; } } public class TestDriver{ public static void main(String[] args){ int var = Test.timesTwo(5); System.out.println(var); } } For your final exercise, create a class called ManyLinkedLists. It will contain a static method called createLinkedList(). That method takes an argument that is...
Create a class called Login which contains a HashMap as a private attribute. It should also have an instance method called loadCredentials which acccepts the two arrays. It will load the Hash Map with key/value pairs based on the two arrays above. The userNames should be the keys and the passwords the values. private static String[] userNameArray = {"John", "Steve", "Bonnie", "Kylie", "Logan", "Robert"); private static String) passwordArray = {"1111", "2222", "3333", "4444", "5555", "6666"}; Create a login method in...
Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...
Java two dimensional arrays Create a method named curiousNumber that takes an integer named num as a parameter and returns a boolean. You can assume the num will be a positive integer. The curiousNumber method should determine whether num is a curious number. A curious number is a number that is equal to the sum of the factorial of each of its digits. For example, 145 is a curious number because 145 = 1! + 4! + 5!. sample: boolean...