File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes purpose of a function Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "purpose of a function" Watch "purpose of a function" New topic
Author

purpose of a function

alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 189
the first loop switches the i'th member backoward like in insertion sort till it gets a valuse smalle then maxvalue
but it switch always with a[i-2]
so i cant see the purpose


the second loop does a similar thing
but i cant see what is the general purpose
??


Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 2686
The value of i changes each time through the loop so a[i-2] refers to a different element of the array each time.

The first loop moves some elements of the array forward two elements.
The second loop moves some elements of the array forward one element.

Try printing out the values of the array at the start and after each loop if you're still not sure what is happening.


Joanne
 
 
subject: purpose of a function
 
Threads others viewed
max and min in array?
Wanted: Java2D example of zooming and panning with scroll bars
double precision floating point
Concurrent Modification Exception??
Problem with appearance of JProgressBar
developer file tools