+ 1

Beginners question: changeable string but saving all "entries"

This is really beginners level and naive(!!!!) programming, please think simple. Learning with BlueJ (not voluntarily, that's my Prof's choice) public class WikiEntry { ... private String autor; private int version; // left out quite a bit here public void getAuthor (String newAutor) { autor = newAutor; } //another method left out that let's me change the article and adds a plus one to the int version } What I would love to do: To be able to change the Autor (that already works) but it would be awesome, if it could also safe/store/collect all the Autor Strings in a list automatically. Does that work? Like every time the Autor gets changed it creates a new entry for a list. No need to change the list or to reset or anything else. Thank you very much for your help, I really appreciate helpful answers on this probably very basic problem...

10th Dec 2019, 7:44 PM
Alisa Jääkarhu
Alisa Jääkarhu - avatar
4 Antworten
+ 2
I have used a HashSet because I think you should not store every author. Only unique authors. https://code.sololearn.com/caEoUcuFj4ng/?ref=app
10th Dec 2019, 8:29 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Yup, that's a better implementation, didn't think on that
10th Dec 2019, 9:44 PM
Deroman
Deroman - avatar
+ 1
Thank you very much, Denise. It works beautifully :)
12th Dec 2019, 12:35 PM
Alisa Jääkarhu
Alisa Jääkarhu - avatar
0
I think what you need is a static list. This is a basic implementation of what you want: https://code.sololearn.com/c3uv72QbrYpq/?ref=app
10th Dec 2019, 8:10 PM
Deroman
Deroman - avatar