## wallet123 15

``````public class Array {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

String ctr="";
int size= Integer.parseInt(JOptionPane.showInputDialog("Enter any 10 numbers:"));
String num[]= new String [11];
for (int i=1; i<=size;i++){
num[i]=JOptionPane.showInputDialog("num["+i+"];");
ctr=ctr+num[i]+ " ";
}
JOptionPane.showMessageDialog(null, ctr);

}

}``````

thats my code, what should happen in there is that, the numbers that i have inputted should be shown on an ascending and descending order.

i still dont know how to use sort.array so i guess ill have to do it on another way..

## stultuske 1,092

well, just do a quick google search on 'java bubblesort'.
it's quite easy and you'll find enough examples that 'll help you solve this in no time.

## wallet123 15

well, just do a quick google search on 'java bubblesort'.
it's quite easy and you'll find enough examples that 'll help you solve this in no time.

sir, our teacher asked us to do this by the use of relational operators.. :(

## stultuske 1,092

sir, our teacher asked us to do this by the use of relational operators.. :(

bubblesort is not a framework or anything like that, it's a way to implement the logic, and it uses relational operators. bubblesort just means that you compare the values in a certain order.

## wallet123 15

bubblesort is not a framework or anything like that, it's a way to implement the logic, and it uses relational operators. bubblesort just means that you compare the values in a certain order.

this is what i did...

``````public static void main(String[] args) {
// TODO Auto-generated method stub

String ctr="";

JOptionPane.showMessageDialog(null,"Enter any 10 numbers:");
String points[] = new String[10];

for (int i=1; i<=10;i++){

points[i]=JOptionPane.showInputDialog("num["+i+"];");

ctr = ctr+points[i]+ " ";
Arrays.sort(points);
Arrays.sort(points, Collections.reverseOrder());
}

JOptionPane.showMessageDialog(null, "Numbers Entered: "+ctr);
JOptionPane.showMessageDialog(null, Arrays.toString(points));

}

}``````

but i cant understand what wrong here..that bubble sort also..i cant understand it too, this thing is much understandable for me..
thank you

## stultuske 1,092

maybe, but since you have to use relational operators: you aren't using them.

what I mean with bubblesort is:

``````arrayInt = readNumbers
int index = 0;
do arrayLength-1 times
do arrayLength-1 times
if arrayInt[index] is smaller than arrayInt[index+1]
swapPlaces arrayInt[index] and arrayInt[index+1]
index = index + 1;
end-do``````

this way, you have sorted your array using bubblesort

## wallet123 15

yes...but the other bubblesort tutorials that i have seen has two mains..thats why i cant understand it..ill try this one..!

i have to pass it after two hours so i need to do it fast hehe!

## stultuske 1,092

it is impossible for one java class to have more than one main method
probably they were used to show several different sortings. can you show me what link you've seen that at?

## wallet123 15

it is impossible for one java class to have more than one main method
probably they were used to show several different sortings. can you show me what link you've seen that at?

http://www.roseindia.net/java/beginners/arrayexamples/bubbleSort.shtml
this is not the one that i have seen but similar top this..i deleted my history so i cant find it!

## stultuske 1,092

well ... that link only has one main method, and it has everything you need. basically, your entire application is not only in there, but it is explained step by step.

## wallet123 15

it is impossible for one java class to have more than one main method
probably they were used to show several different sortings. can you show me what link you've seen that at?

hi i did use bubblesort..i understand it now but im still having difficulties because it wont run correctly please see my new thread