![]() |
java bubble sort help
Right i cant get it to work and im out of ideas so some programmring guru plz help T__T
this is my bubblesort class file: :
public class sort{:
//note that it's in a case. and the error i get when i javac it :
// |
what's film? is there a class called film? you're passing film into the sort method, but that's the name of the variable, when you create film, you must do something like [Class] film = new [Class]() the name of the Class is the Type of variable you're passing through.
|
oh crap forgot that. Film is a "array" (i think... im translating from swedish -> english so it might be wrong)
i used it to :
DVDDaAr film[]=new DVDDaAr[100];DVDDAaAr is the main class file that sorts the other information that i send in (it works ). |
ok, so DVDaAr data[] is what you wanna accept in sort()
|
So it's
:
sort.bubbelSort(DVDDaAr data[]);? or did i get it wrong? edit: changed some stuff. i Changed :
Public static void bubbelSort(film data[]){and :
for (int m = data.lenght -1; m > 0; m--){:
every .langd .hamtaLangd is a getter which returns a int. and now im stuck with these 2 last errors :
.\sort.java:8: unexpected type |
what's hamtaLangd?
|
a method that returns a private value
|
looks like you're not calling it according to it's signature
|
Hello all, I'm new to this forum, but I consider myself an expert in Java (as well as in 6 other computer languages). I think I can help out with this problem if anyone's still paying attention to this thread ....
I wrote a small C++ routine that implements the Bubble Sort algorithm a while back and it should be able to be ported to Java quite easily. Here it is: void SortObject::bubbleSort () { int i; int tmp; for ( i = 0; i < count - 1; i++ ) { if ( array[i] > array[i+1] ) { tmp = array[i]; array[i] = array[i+1]; array[i+1] = tmp; i = 0; } } } -------------------------------------------------------------------------------- Download SortObject++: veritedonato.cihost.com/sort.zip MainWebsite: veritassoftwarecreations.net/ |
his problem wasn't the algorithm, he had some syntax errors in his code.
|
| All times are GMT -5. The time now is 4:27 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC