It can also be other symbols. When you have this kind of problem, you should consider changing the storage location first (you can split it into arrays according to the specified string, and only add delimiters when the length is greater than 1, otherwise there is no need to add it at the end)
Boolean isNotEmpty = StringUtils.isNotBlank(this.version); Boolean lastIndex = false; if(isNotEmpty){ lastIndex = ",".equals(this.version.substring(version.length()-1)); } if(isNotEmpty && lastIndex){ return this.version.substring(0,version.length()-1); }else{ return this.version; }