Hallo ihr lieben,
hier mein sortierProgramm,
public class BubbleSort {
public static void sort(int[]A){
boolean swapped=false;
int n=A.length;
do
{
swapped=false;
for(int i=0; i<n-1;++i){
if(A>A[i+1]){
swap(A,A[i+1]);
swapped=true;
}
}
}
while(swapped&&n>0);
public static void swap(int a,int b){
int temp=A[a];
A[a]=A;
A=temp;
swapped=true;
}
}
public static void main(String[] args) {
int[]B={2,7,12,6,9,0};
sort(B);
for (int i=0; i<B.length; i++)
System.out.print(B+" ");
}
}
die methode swap wird nicht akzeptiert und gibt folgende fehlermeldung
The method swap(int, int) is undefined for the type BubbleSort
void is an invalid type for the variable swap
kann mir einer helfen?warum ist das so, und wie kann ich es verbessern?
danke
hier mein sortierProgramm,
public class BubbleSort {
public static void sort(int[]A){
boolean swapped=false;
int n=A.length;
do
{
swapped=false;
for(int i=0; i<n-1;++i){
if(A>A[i+1]){
swap(A,A[i+1]);
swapped=true;
}
}
}
while(swapped&&n>0);
public static void swap(int a,int b){
int temp=A[a];
A[a]=A;
A=temp;
swapped=true;
}
}
public static void main(String[] args) {
int[]B={2,7,12,6,9,0};
sort(B);
for (int i=0; i<B.length; i++)
System.out.print(B+" ");
}
}
die methode swap wird nicht akzeptiert und gibt folgende fehlermeldung
The method swap(int, int) is undefined for the type BubbleSort
void is an invalid type for the variable swap
kann mir einer helfen?warum ist das so, und wie kann ich es verbessern?
danke