The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 408 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
write a method that returns an array composed of all elements in an array of chars in reverse order
Â
this is what I have so far:
Â
public class PrintReverseArray
Â
{
public static void main(String [] args)
{
char [] array ={'a','b','c','d','e'};
//printing all the elements
System.out.print("The elements are: ");
for (int i=0; i< array.length; i++)
System.out.print(array[i]+" ");
System.out.println();
//print in reverse order
//System.out.println("The elements in reverse order are: ");
//arrayReverse(array)
= arrayReverse(array);
 Â
}//end main
public static void arrayReverse(char [] cArray)
{
for (int i=cArray.length-1; i>=0; i--)
System.out.print(cArray[i]+" ");
}//method arrayReverse
public static char[] reverseArray(char [] cArray)
{
char [] tempArray = new char[cArray.length];
for (int i = cArray.length-1; i>=0; i--)
tempArray[cArray.length-1-i]=cArray[i];
return tempArray;
}//end reverseArray
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------