Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We are going to do more array practice but with arrays of Strings Write a class:

ID: 3692664 • Letter: W

Question

We are going to do more array practice but with arrays of Strings Write a class: ArrayMethods with all of the following methods: 1) public void printArray(Stringl arraytoPrint) //prints an array of String with commas separating items and no trailing comma 2) public void swapltems(StringD array ToSwap) /swap first item in array with last item in the array 3) public boolean alphabetical(String) arrayToCheck) //returns true if the array is in alphabetical order A->Z Test with this main public static void main Stringl args)H StringD myArray ('This", "may, "or, 'may. "not", "be, fantastic' System.out.print Original array: " am-printAraymyArray) System.out.printAfter swap array: System.out.printin'is the array in alphabetical order? am.alphabetical(myArrayl): Noxt Provious ighight allManch case

Explanation / Answer

calss ArrayMethods{
  


public void printArray(String[] myArray) {
for (int i=0;i<=myArray.length;i++){
System.out.printf("%s ", myArray[i]);
System.out.println();
}
   }

   public void swapItems(String[] myArray){

   String hold = myArray[0];
        myArray[0] = myArray[myArray.length - 1] ;
        myArray[myArray.length - 1] = hold;
   for (int k = 0; k < 5; k++) {
System.out.print(myArray[k]);
           }

System.out.println("");
   }

public static void main(String[] args){

ArrayMethods am = new ArraMethods();

String [] myArray= {"This","May","or","may","not","be","Fantastic"};
System.out.println("Original Array :")
am.printArray(myArray);
System.out.println("After swap array :")

am.swapItems(myArray);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote