In order to make my code more readable, I decided to create a String, and then to use it inside an "algorithm" (similar to the following):
JsonArray users = import();
String currentUser = db.getName(currentID);
for (int i=0; i < users.size(); i++) {
user = (JsonObject) users.get(i);
if (user.get("username").getAsString().equals(currentUser)) {
System.out.println("The user's index is " + i);
}
}
currentUser = null; // This line raises the warning
When the "algorithm" is done, I want to delete the String - and therefore I assign it null
(after reading this).
However IntelliJ doesn't seem to like it, because it raises the obvious warning:
The value null assigned to 'currentUser' is never used (...)
Is there a better way to delete objects that I'm missing, or is it just a bug that I can ignore?