31 lines
2.4 KiB
Markdown
31 lines
2.4 KiB
Markdown
# PR1_Aufgabensammlung_Erstelle_Arraylist
|
|
In diesem Repo finden Sie die Aufgabenstellung mit Tests.
|
|
Sie müssen lediglich die Klasse MeineArrayList fertig implementieren.
|
|
Mit Hilfe der Tests wissen Sie, ob die Aufgabe korrekt ist.
|
|
|
|
# Aufgabe
|
|
Implementieren Sie die Klasse MeineArrayList so, dass sie die Grundlegenden Funktionen einer ArrayList\<String> hat ohne ArrayList<> in der Klasse zu verwenden.
|
|
|
|
## Zu implementierende Methoden
|
|
|
|
Die folgenden Methoden sind in der Klasse zu implementieren. Die Methoden und ihre Beschreibung sind der offiziellen Java documentation zu entnehmen. https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
|
|
|
|
Achtung! Die Methoden müssen für die Aufgabe ein wenig angepasst werden.
|
|
|
|
| Methode | Parameter | Rückgabetyp | Rückgabewert |
|
|
| - | - | - | - |
|
|
| add(String n) | n: String to be appended | void
|
|
| add(int index, String n) | index: index at which the specified String is to be inserted <br> n: String to be inserted | Boolean | true: erfolgreich <br> false: fehlgeschlagen
|
|
| addAll(MeineArrayList liste) | liste: list wich gets appended | void |
|
|
| addAll(int index, MeineArrayList liste) | index: index at which to insert the first element <br> list: list containing Strings to be added to this list | Boolean | true: erfolgreich <br> false: fehlgeschlagen
|
|
clear() | | void | |
|
|
contains(String s) | s: String to search | Boolean | true: the same String exists (s.eaquals()) in the list <br> false: the String doesn't exists in the list.
|
|
get(int index) | index: index to return | String | returns the String from the specifed index |
|
|
indexOf(String s) | s: String to search | int | Returns the index of the first eaqual String in this list, or -1 if this list does not contain the element. |
|
|
isEmpty() | | Boolean | Returns true if the list contains no elements. |
|
|
remove(int index) | index: index to remove | String | removes the specified index and returns the removed String.
|
|
set(int index, String s) | index: index to replace <br> s: String to replace with. | Boolean | Replaces the String at the specified position in this list with the specified String. |
|
|
size() | | int | Returns the number of elements in this list.
|
|
toArray() | | String[] | Returns an array containing all Strings in this list in proper sequence (from first to last String). The returned Array is a deep copy. This means that if you change a String in the returned Array the String isn't changed in this list.
|
|
|