Yes, you are missing out on a very important concept.
Since Strings are immutable, i.e you cannot change the values of an existing object. And in your code, you are discarding the value, returned by the replace().
So, what you need to do is:
//You do not need the if statement
String demo = "One, Two, Three, Four and Five" ;
demo = demo.replace(“and”, “,”);
Hope this helps!