Hallo!
Ich habe grundsätzlich ein Problem mit dem return-Befehl.
Worauf kommt es an auf was muss geachtet werden??
Dieses Programm funzt z.B nicht
class Sortieren
{
public static int[] bubblesort()
{
int[] abc = {4,3,7,1,2,9,5};
int zwischenspeicher;
for ( int i=0; i<= 6; i++ ) {
for ( int j=i+1; j<= 7; j++ ) {
if ( abc[j]<abc[i] ) {
zwischenspeicher = abc[j];
abc[j] = abc[i];
abc[i] = zwischenspeicher;
System.out.println(abc);
}
}
}
return bubblesort();
}
public static void main(String[] args)
{
System.out.println(bubblesort());
}
}
Vielleicht kann mich jemand aufklären.
Grüße
Ich habe grundsätzlich ein Problem mit dem return-Befehl.
Worauf kommt es an auf was muss geachtet werden??
Dieses Programm funzt z.B nicht
class Sortieren
{
public static int[] bubblesort()
{
int[] abc = {4,3,7,1,2,9,5};
int zwischenspeicher;
for ( int i=0; i<= 6; i++ ) {
for ( int j=i+1; j<= 7; j++ ) {
if ( abc[j]<abc[i] ) {
zwischenspeicher = abc[j];
abc[j] = abc[i];
abc[i] = zwischenspeicher;
System.out.println(abc);
}
}
}
return bubblesort();
}
public static void main(String[] args)
{
System.out.println(bubblesort());
}
}
Vielleicht kann mich jemand aufklären.
Grüße
Comment