Page 1 of 1

JAVA

Posted: Sat Feb 19, 2022 3:20 pm
by answerhappygod
JAVA
Java 1
Java 1 (50.28 KiB) Viewed 28 times
Exercise 2: Write array methods that carry out the following tasks for an array of integers by creating and completing the “ArrayMethods” class below. Add documentation comments for each method. Provide a test program called 'Lab5_yourID.java” that tests methods of Array Methods class. In your test program, use random class to generate array values. public class ArrayMethods private int [ ] values; //declare instant variables public ArrayMethods (int[] initialValues) {values = initialValues:} //constructor public void shiftRight() {...} public boolean adjacentDuplicate() {---} Method shiftRight: that shifts all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would be transformed into 25 1 4 19 16. • Method adjacentDuplicate: returns true if the array has two adjacent duplicate elements.