I am trying to replace the "," in the string with an empty string "". I believe the following code is correct, but when I run it with Eclipse. It doesn't work. What's wrong with my code and how should I correct it
String fullName = "lastname, firstname", lastName, firstName;
String[] parts = fullName.split(" ");
String firstPart = parts[0];
String secondPart = parts[1];
if (firstPart.contains(",")) {
firstPart.replace(",", "");
firstPart.trim();
secondPart.trim();
lastName = firstPart;
firstName = secondPart; }