aspose file tools*
The moose likes Beginning Java and the fly likes Bubble Sort>>>Nice program but??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Bubble Sort>>>Nice program but???" Watch "Bubble Sort>>>Nice program but???" New topic
Author

Bubble Sort>>>Nice program but???

Um Hassan
Greenhorn

Joined: Jun 16, 2009
Posts: 10
Hi everybody,
I'm a student in java and I've this program in my assignment. I tried to do it(sorting with bubble is really nice),but I have problem with run this program? Any help I'll glad to thank you.
Cheers,

import java.awt.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Random;


public class bubblesort
{
private static void bubble(comparable[] a, int n)
{
// bubbling pass
for(int i=1;i<n-1;i++)
if(a[i].compareTo(a[i+1])>0)
MyMath.swap(a,i,i+1);
}
public static void bubblesort(comparable[] a)
{
// bubble sort
for(int i=a.length;i>1;i--)
bubble(a,i);
}

}
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 605

So what is the problem that you are facing when you run this program?


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
siddhu Math
Ranch Hand

Joined: Aug 10, 2006
Posts: 46
Could you just append the error trace over here .....
Um Hassan
Greenhorn

Joined: Jun 16, 2009
Posts: 10
maybe relation between importing and comparable and MyMath , really I don't know?
Here, attachement photo for error message will explain.
Regards,


[Thumbnail for error_ms.JPG]

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
The JDK does not have a class "comparable", so unless that's one of your classes, that would be a problem. Note that Java is case-sensitive, maybe you meant "Comparable"?


Ping & DNS - my free Android networking tools app
Um Hassan
Greenhorn

Joined: Jun 16, 2009
Posts: 10
It isn't my own class, this program is already in textbook and I applied the compile.
Thanks alot.. Sam, siddhu Math and Ulf Dittmer
Ulf Dittmer , you are right about Java is case-sensitive. However what about (MyMath) it's still ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18745
    
  40

However what about (MyMath) it's still ?


There is no such class in the core Java API. And considering that the class name starts with "My", it is likely something that you have written (or supposed to have written) as part of your assignment.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bubble Sort>>>Nice program but???