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 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 597

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: 39537
    
  27
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 - updated with new look and Ping home screen widget
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: 18103
    
  39

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???
 
Similar Threads
Searching an array - output problems - Please help!!
Deep cloning not working
Generics - what does it mean "? super T"?
Sorting array on command line
sorting an array