Java Probleme
-
Hallo alle zusammen kann mir jemand erklären wie ich bei der Aufgabe die ersten Lücken auffüllen kann ?
Ich habe grosse Probleme mit java .
Dies ist nur ne übungsaufgabe ,keine Aufgabe zum abgeben .
Daher wäre es schön wenn mir jemand helfen könnte bei der AufgabeHoffe mir kann jemand helfen
-
Muss diesen Code in den Lücken ausfüllen . Wie mache ich das ?
import java.util.Comparator; import java.util.Vector; public class Sorter<T> { enum Mode { DESCENDING, ASCENDING } private boolean toBeSwapped(T a, T b, Comparator<T> comp, Mode mode) { boolean condition; switch (mode) { case ASCENDING: condition = __________; break; case DESCENDING: condition = __________; break; default: throw new IllegalStateException(); } ____________; } public Vector<T> sort(Vector<T> list, Comparator<T> comp, Mode mode) { if(___________________________) return null; for(int a = 0; ; ) { for(int b = 0; ; ) { if(compare( , , comp, mode)) { _______________; } } } } }
-
Dieser Thread wurde von Moderator/in camper aus dem Forum C++ (alle ISO-Standards) in das Forum Java verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Hat jemand Tipps ?
-
private boolean toBeSwapped(T a, T b, Comparator<T> comp, Mode mode) { boolean condition; switch (mode) { case ASCENDING: condition = comp.compare(a,b) > 0; break; case DESCENDING: condition = comp.compare(a,b) <= 0; break; default: throw new IllegalStateException(); } return condition; }
Der erste Teil könnte so aussehen.
-
Könnten die anderen Lücken so aussehen ?
Bei den anderen 2 Lücken habe ich keine Idee
public Vector<T> sort(Vector<T> list, Comparator<T> comp, Mode mode) { if(___________________________) return null; for(int a = 0;b>a ;b++ ) { for(int b = 0;a>b ;a++ ) { if(compare( a,b , comp, mode)) { _______________; } } } } }
-
phone33 schrieb:
Könnten die anderen Lücken so aussehen ?
Bei den anderen 2 Lücken habe ich keine Idee
public Vector<T> sort(Vector<T> list, Comparator<T> comp, Mode mode) { if(___________________________) return null; for(int a = 0;b>a ;b++ ) { for(int b = 0;a>b ;a++ ) { if(compare( a,b , comp, mode)) { _______________; } } } } }
ich tippe mal auf sowas:
public Vector<T> sort(Vector<T> list, Comparator<T> comp, Mode mode) { if(list.isEmpty()) return null; for(int a = 0; a<list.size(); a++ ) { for(int b = 0; b<list.size(); b++) { if(compare(list.get(a), list.get(b), comp, mode)) { Collections.swap(list, a, b); } } } }
... aber da fehlt noch ein return. vermutlich 'return list;'
-
Woher kommt plötzlich die Funktion empty her ?
Ist die bei javadoc oder wie ?
-
phone33 schrieb:
Woher kommt plötzlich die Funktion empty her ?
vom List-Interface.
--> https://docs.oracle.com/javase/7/docs/api/java/util/List.html