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..
please help me thank you

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.

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.. :(

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.

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

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

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!

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?

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.