更新时间:2023-11-05 14:23:34
始终重新分配。
password = password.replace("Password: ", " ");
字符串在Java中是不可变的,这意味着您无法修改它的现有实例。通过重新分配它,您将捕获字符串的新值到现有变量中。
Strings are immutable in Java, meaning you can't modify an existing instance of it. By re-assigning it, you'll be capturing the new value of the string into an existing variable.