I know how Java passes object references, but this piece of code really confused me.
Introduction: when the application starts, the service retrieves JSON data, parses it, and compares it with data models. Then we need to load a specific list into ListView
, but we also need to sort and cancel it first. The line of code looks like this:
Collections.sort(Datastorage.getInstance().getHistoryKeys());
Collections.reverse(Datastorage.getInstance().getHistoryKeys());
where the called method getHistoryKeys()
simply returns a list object populated by the service when the application starts.
Is this really allowed in Java?
I would call it that, and it seems like I'm wrong.
ArrayList<Key> keysList = Datastorage.getInstance().getHistoryKeys()
Collections.sort(keysList);
Collections.reverse(keysList);
Am I the only one who considers my code more understandable and understandable for those who will support the project after me?