Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bubble Sort>>>Nice program but???

 
Um Hassan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the problem that you are facing when you run this program?
 
siddhu Math
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you just append the error trace over here .....
 
Um Hassan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe relation between importing and comparable and MyMath , really I don't know?
Here, attachement photo for error message will explain.
Regards,
error_ms.JPG
[Thumbnail for error_ms.JPG]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?
 
Um Hassan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20990
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic