Help me with references
- From: "Masamunexiii" <jkamdar@xxxxxxxxxxxxxxxx>
- Date: 14 Aug 2005 16:02:46 -0700
i am working on bubblesort method and the swap method is giving trouble
because the values are being change,there are byval. So i looking for
a way to make swap work and change the values of the arguments.
public class a {
public static void main(String[] args) {
// create the array
int[] array = {4,2,3,5,6,7,8,10,9,11};
functions a = new functions();
a.randomload(array);
a.bubblesort(array);
}
}
class functions {
public void randomload(int[] array) {
int count;
for (count = 0; count<= array.length-1; count++)
array[count] = (int) (java.lang.Math.random() * 10);
}
public void bubblesort(int[] array) {
int count;
boolean blnswap;
blnswap = true;
while (blnswap = true) {
blnswap = false;
for(count = 0; count <= array.length -2; count++)
if (array[count] > array[count + 1]) {
swap(array[count],array[count +1]);
blnswap = true;
}
}
}
public void swap(int num,int num2) {
int temp;
temp = num;
num = num2;
num2 = temp;
}
}
.
- Follow-Ups:
- Re: Help me with references
- From: Kenneth P. Turvey
- Re: Help me with references
- From: googmeister
- Re: Help me with references
- From: Patricia Shanahan
- Re: Help me with references
- Prev by Date: importing external package into applet..
- Next by Date: Re: Help me with references
- Previous by thread: importing external package into applet..
- Next by thread: Re: Help me with references
- Index(es):
Relevant Pages
|